I have a thread and I need to wait for its result, like this:
t1.start();
while (variableModifiedByMyThread == null) {
/* do nothing */
}
// "t1" set the value of "variableModifiedByMyThread"
The code above is working, but not a very nice solution...
Is this code doing the same thing (is it waiting for the "t1" thread)?
t1.start();
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
// "t1" thread finished