Skip to content

Instantly share code, notes, and snippets.

@nalitzis
Created April 5, 2013 20:20
Show Gist options
  • Save nalitzis/5322317 to your computer and use it in GitHub Desktop.
Save nalitzis/5322317 to your computer and use it in GitHub Desktop.
boolean signal = false;
synchMethod(){
// do something...
callAsycnMethod(callback);
synchronized(this){
while(!signal){
try{
this.wait();
}catch(InterruptedException e){}
}
}
//return after the callback finished
}
private class CallbackImpl implements Callback{
public void onComplete(){
synchronized(this){
this.signal = true;
this.notify();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment