A site devoted mostly to everything related to Information Technology under the sun - among other things.

Sunday, March 28, 2010

Concurrency in Java 5

J2SE 5 very much extends and expands the concurrency model of Java. The very useful concurrency communication classes such as (bounded and unbounded) queues are introduced.

One of the best parts of new improved Java concurrency model is the new java.util.concurrent.BlockingQueue interface.

LinkedBlockingQueues and ArrayBlockingQueues do away with wait(), notify() and notifyAll() style of coding. Add to that Synchronized queues, which are simply amazing, as well as DelayQueue classes and PriorityBlockingQueues and you have yourself a whole lot of threading fun!

Other useful classes are CountDownLatch, CyclicBarrier, Executor,
CachedThreadPools, FixedThreadPools, SingleThreadExecutors, ExecutorServices, Futures, and Callable.

I think it is a good idea to look into learning synchronous, asynchronous queues, and cached threading pools, and then delve into performance considerations for atomic, lock, and concurrent methods of class, method, and attribute concurrency.

Note that there are command line switches important to concurrent programming (-X*) and also that there Runtime classes designed to help avoid OutOfMemory heap problems.

Some of these exciting stuff is covered in the "Thinking in Java 4" by Bruce Eckel but that book does not concentrate on concurrent programming.

The book to read is:

Java Concurrency in Practice
by Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea

No comments:

About Me

My photo
I had been a senior software developer working for HP and GM. I am interested in intelligent and scientific computing. I am passionate about computers as enablers for human imagination. The contents of this site are not in any way, shape, or form endorsed, approved, or otherwise authorized by HP, its subsidiaries, or its officers and shareholders.

Blog Archive