Created
April 5, 2013 20:20
-
-
Save nalitzis/5322317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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