Fixed issue where empty list was freezing the app

This commit is contained in:
Ziver Koc 2014-08-07 15:23:41 +02:00
parent 450ca0af17
commit e066e4431b

View file

@ -72,12 +72,17 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
try { thread.wait(); }catch(InterruptedException e) {log.error(null,e);}
}
}
// Sleep for some time to get correct status
try{ Thread.sleep(20); }catch(Exception e){log.error(null,e);}
}
public synchronized void terminate(){
private void terminateNonBlock(){
terminate = true;
if(currentlyActive != null)
currentlyActive.terminate();
}
public synchronized void terminate(){
terminateNonBlock();
// Wait for the execution to finnish
if(isRunning()){
@ -108,7 +113,7 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
while(!terminate) {
if(behaviours.isEmpty()) {
currentlyActive = null;
terminate();
terminateNonBlock();
synchronized (thread){thread.notifyAll();}
break;
}