Friday 2 May 2008

Java Concurrency is the next big thing, reason why you would learn this ?

I have recently implemented the concurrent package and basis of my experience I thought this concept is worth promoting. believe me i am a bit more techie now, because a lot of concurrency expertise comes now for free with Java :))

First I would talk here why you would invest your time learning this piece of information when you can spend it watching some movie ? Becuase it can save you those code debugging days later..

The Java platform includes a new package of concurrency utilities.Just as the Collections Framework simplified the organization and manipulation of in-memory data by providing implementations of commonly used data structures, the Concurrency Utilities aims to simplify the development of multithreaded applications. So in summary you have lot of things already wrapped for you.

The Concurrency Utilities include the following in built features like
* A high-performance, flexible thread pool
* A framework for asynchronous execution of tasks
* A host of collection classes optimized for concurrent access
* A synchronization utilities such as counting semaphores, atomic variables, locks, condition variables etc etc.

Let us put it in other words. When you need a list like data structure do you define your own list implementation ?
when you need a map like structure you simply use some hashmap .. am I right?
So guys something similar is this package. Solves lot of your headaches :) the only thing you need to do is a little bit of more learning :)

Using the Concurrency Utilities, instead of developing components from scratch such as thread pools yourself, it offers a number of advantages:

* Reduced programming effort because It is far easier to use a standard class than to develop it yourself.

* Increased performance. The implementations in the Concurrency Utilities were developed and peer-reviewed by concurrency and performance experts, these implementations are likely to be faster and more scalable than a typical implementation, even by a skilled developer. So you got this expertise in-built in your codes for free ? don't tell anybody :)

* Increased reliability. Developing concurrent classes is difficult atleast not easy to design -- the low-level concurrency primitives provided by the Java language (synchronized, volatile, wait(), notify(), and notifyAll()) are difficult to use correctly, and errors using these facilities can be difficult to detect and debug.
By using standardized, extensively tested concurrency building blocks, many potential sources of threading hazards such as deadlock, starvation, race conditions, or excessive context switching are eliminated. The concurrency utilities have been carefully audited for deadlock, starvation, and race conditions.

* Improved maintainability. Programs which use standard library classes are easier to understand and maintain than those which rely on complicated, homegrown classes.

* Increased productivity. Developers are likely to already understand the standard library classes, so there is no need to learn the API and behavior of ad-hoc concurrent components. Additionally, concurrent applications are far simpler to debug when they are built on reliable, well-tested components.

the Concurrency Utilities to implement a concurrent application can help you make your program clearer, shorter, faster, more reliable, more scalable, easier to write, easier to read, and easier to maintain.