This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It sounds like you're asking how to create a critical section of code. In Java, that's very easy. Just use the key word "synchronized". It's typically used to synchronize an entire method, by you can also synchronize a block of code if you want.