Something like this is possible with synchronized, or I need to use java.util...Lock:
synchronized
java.util...Lock
public void outer() { synchronized(lock) { inner(); } } public void inner() { thing1(); release(lock) { result = doLongNetworkRequest(); } thing2(result); }
You cannot release monitors held during a synchronized block, unfortunately. You will need to use a lock or two to do what you want.
You can use java.util.concurrent.locks. They have lock()andunlock()
java.util.concurrent.locks
lock()
unlock()