Sync version of async method
Have a look at CountDownLatch. You can emulate the desired synchronous behaviour with something like this: private CountDownLatch doneSignal = new CountDownLatch(1); void main() throws InterruptedException{ asyncDoSomething(); //wait until doneSignal.countDown() is called doneSignal.await(); } void onFinishDoSomething(){ //do something … //then signal the end of work doneSignal.countDown(); } You can also achieve the same behaviour using … Read more