...
One of the major strengths
of the Java programming language
is its built-in support for multi-threaded programs. An object that is shared between multiple threads can be locked in order to synchronize its access. Java provides primitives to designate critical code regions, which act on a shared object and which may be executed only by one thread at a time. The ¯rst thread that enters the region locks the shared object. When a second thread is about to enter the same region, it must wait until the ¯rst thread has unlocked the object again. The client compiler translates the appropriate Java bytecodes into machine code that implements an e±cient and lightweight locking mechanism.