0

So, I'm searching on net for a while and now I'm confused... do I need to explicitly end thread after code is executed or thread does it automatically?
Code:

Runnable waitForInput = new Runnable() {
    public void run() {
        while (!inputOK) {
            try {
               Thread.sleep(100);
            } catch (Exception e) {}
        }
        if (!ret_val.equals("")) {
            port = ret_val;
        }
        inputOK = false;
        ret_val = "";
    }
};      
Thread inputW = new Thread(waitForInput);
inputW.start();
mmBs
  • 8,421
  • 6
  • 38
  • 46
mgulan
  • 795
  • 1
  • 14
  • 33

1 Answers1

3

The Thread ends when the method run ends. Since you have while loop you have to force explicitly the exit condition

Blackbelt
  • 156,034
  • 29
  • 297
  • 305