You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Synchronization and Object Locking

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.

  • No labels