Wednesday, December 13, 2006

Java Concurrency

Concurrency according to is following:

1. Simultaneous occurrence; coincidence: the concurrence of several unusual events. OR,
2. Acting together as of agents or circumstances or events

Example of concurrent application could be following:

1. The streaming audio application must simultaneously read the digital audio off the network, decompress it, manage playback, and update its display.
2. The word processor should always be ready to respond to keyboard and mouse events, no matter how busy it is reformatting text or updating the display.

The Java platform is designed from the ground up to support concurrent programming, with basic concurrency support in the Java programming language and the Java class libraries. Since version 5.0, the Java platform has also included high-level concurrency APIs. This lesson introduces the platform's basic concurrency support and summarizes some of the high-level APIs in the java.util.concurrent packages. They are following:
    *  Lock objects support locking idioms that simplify many concurrent applications.
    * Executors define a high-level API for launching and managing threads. Executor implementations provided by java.util.concurrent provide thread pool management suitable for large-scale applications.
    * Concurrent collections make it easier to manage large collections of data, and can greatly reduce the need for synchronization.
    * Atomic variables have features that minimize synchronization and help avoid memory consistency errors.
For detail, visit

Going a little bit over basics, in concurrent programming, there are two basic units of execution: processes and threads. In the Java programming language, concurrent programming is mostly concerned with threads. However, processes are also important.


A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space.

Processes are often seen as synonymous with programs or applications. However, what the user sees as a single application may in fact be a set of cooperating processes.

Most implementations of the Java virtual machine run as a single process. A Java application can create additional processes using a ProcessBuilder object.


Threads are sometimes called lightweight processes. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process.

Threads exist within a process - every process has at least one. Threads share the process's resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

Multithreaded execution is an essential feature of the Java platform.from the application programmer's point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads.


Post a Comment

<< Home