I have a method that has to return a boolean value. The method has an asynchronous call to run method. In the run method, i have to set variable in the enclosing method. below is my code.
private boolean isTrue() {
boolean userAnswer;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
userAnswer = MessageDialog.openQuestion(new Shell(), "some message", "some question?");
}
});
return userAnswer;
}
This code gives error -- "userAnswer" has to be final, and if i make it final i cant assign a value to it. Please suggest a way to handle this scenario.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…