JavaFAQ Home » Good To Know
Java is a multithreaded programming language that makes programming with
threads easier, by providing built-in language support for threads. The
built-in primitives however, such as synchronized blocks,
Object.notify() are insufficient for
many programming tasks. This leads developers to implement their own
high-level synchronization facilities, but given the difficulty of
concurrency issues, their implementations may not be correct, efficient, or
The Java 2 Platform, Standard Edition release 5.0 (J2SE 5.0), which is also
known as Tiger, has provided a new path to multithreading in the Java
programming language. The original mechanisms for coordinating threads with
are now enhanced with new and
sophisticated mechanisms for working with threads. The new mechanisms are
part of the
package, which aims to offer a
standard set of concurrency utilities that will ease the task of developing
multithreaded applications and servers. In addition, such standards will
improve the quality of such applications. The package has been defined
through the Java Community Process as
This article provides an overview and an introductory tutorial to the new
concurrency mechanisms that have been added to J2SE 5.0. It helps developers
get started using the new
java.util.concurrent package and its
Limitations of Built-in Synchronization in J2SE 1.4.x
When writing multithread applications, the issues that may create
difficulties are related to data synchronization; these are the errors that
make design harder, and such errors are hard to detect. Built-in
synchronization (methods and blocks) are fine for many lock-based
applications, but they do have their own limitations, such as:
- No way to back off from an attempt to acquire a lock that is already
held, or to give up after waiting for a specified period of time, or to
cancel a lock attempt after an interrupt.
- No way to alter the semantics of a lock, for example, with respect to
reentrancy, read versus write protection, or fairness.
- No access control for synchronization. Any method can perform
synchronized(obj) for any accessible object.
- Synchronization is done within methods and blocks, thus limiting use to
strict block-structured locking. In other words, you cannot acquire a lock
in one method and release it in another.
Such problems can be overcome by using utility classes to control locking,
such as Mutex, which is another term for a lock. A mutex, however, doesn't
nest like synchronization methods or blocks.
Please read full article
Printer Friendly Page
Send to a Friend
Search here again if you need more info!