Is there a possibility to break a while-loop immediately after the condition gets false?
while(true){
//Backgroundtask is handling appIsRunning boolean
while (appIsRunning) {
Roboter.movement1(); //while Roboter.movement1 is running appIsRunning changes to false
Roboter.movement2();
}
while (!appIsRunning) {
//wait for hardbutton/backgroundtask to set appIsRunning true
}
}
I don't want to wait until the first movement is done, the while should break immediatelty and closes the Roboter.class. And I dont want to check inside the Roboter.class if appIsRunning is true...