I\'m making a program with while loops that execute in this manner:
the main thread does not exit the loop because because in while condition does not anything and checking condition is doing very speedy and while not sense changing variable. you have 2 way for resolve this problem: 1-in while loop waiting for a short time for example 5ms
while(path != null){
try{
Thread.currentThread().sleep(50);
}catch(){
//do nothing
}
}
2-define path variable as volatile:
volatile String path;