I implemented a Runnable and it checks correct if a boolean value turns true.
But i want to return this value to my class where i start the Thread.
I noticed that i can return a value with Future Callables, with them i can just calculate something and return it immediatly but i cant check permanently if the value turns true.
How can i achieve this?
Thank you for your help.
public class ResultChecker implements Runnable{
private DrawView drawView;
public ResultChecker(DrawView drawView){
this.drawView = drawView;
}
public void run() {
boolean run = true;
while(run){
if(drawView.isNextQuestion()){
//RETURN VALUE HERE
run = false;
}
}
}
}
If you want to poll, then create a method in
ResultCheckerthat can be called by the thread that wants the return value.The poller will poll like this:
If you want to return multiple values, you will have to extend this a bit with a queue.