Each object has an implicit lock associated with it. When entering a synchronized block, the process must acquire the object's lock before continuing. The lock is returned upon exiting the synchronized block.
public class SomeClass {
private Object mutex = new Object();
public static synchronized void method1() {
// static methods aquire the class level lock for SomeClass
}
public synchronized void method2() {
// aquire the lock associated with 'this' instance (of SomeClass)
}
public void method3() {
synchronized (mutex) {
// aquire the lock of the mutex object
}
}
}