You can use the synchronized statement:
synchronized(anObject){
performSomeOperation();
}
Every synchronized statement using the same object is guaranted to wait until another thread in such a statement is finished.
Example for Hot Licks comment:
synchronized returntype someMethod(parameters ...){
performSomeOperation();
}
In this example the object which is locked is 'this'.