java.util.concurrent API provides a class called as Lock, which would basically serialize the control in order to access the critical resource. It gives method such as park() and unpark()....
See this page:Â http://www.oracle.com/technetwork/articles/javase/index-140767.html It has a slightly different pattern which is (I think) what you are looking for: try { mutex.acquire(); try { // do something } finally {...