Java 7 Will Evolve to Fine-grained Parallelism
Java's development team understands the multicore revolution and is working hard in offering a new concurrency framework taking into account the new possibilities offered by the new microprocessors. Hence, JDK 7 (Java Development Kit 7) will offer the fork-join framework in order to help Java developers to tackle the multicore revolution using this popular programming language.I'm going to borrow some words from Charles Darwin's "The Origin of the Species" and his theory of evolution: "In a very real sense, nature selected the best adapted varieties to survive and to reproduce. This process has come to be known as natural selection."
I'm pretty sure that developers will select the best adapted programming languages to survive in the parallelism age. This process is also known as natural selection. Programming languages that do not evolve to support multicore programming won't have chances to survive in this new era. Luckily, JDK 7 will offer many improvements that will seduce multicore programmers.
Java supports multithreading since its first version. However, multicore microprocessors were not available when Java was born. This old threading model was useful to create more responsive applications using only one processing core, but it wasn't prepared for high concurrency levels. This model is not suitable for multicore programming that requires many concurrent tasks taking full advantage of all the available cores.
JDK 5 added support for coarse-grained concurrency. However, this model is suitable for multiprocessor systems (MP systems). Therefore, JDK 7 adds support for fine-grained parallelism, offering the developers the possibility to exploit multicore microprocessors using the new fork-join framework.
Definitely, Java is evolving to survive the multicore revolution. This new framework offers the possibility of working with tasks, instead of using more expensive threads. For example, the new package java.util.concurrent.forkjoin, proposed for JDK 7 release offers the following useful base classes:
* RecursiveAction: To represent divide-and-conquer solutions. * RecursiveTask: To represent result-bearing tasks. * AsyncAction: To work with tasks that require asynchronous completion. * CyclicAction: To work with parallel iterative tasks.
The new fork-join tasks are designed to minimize the overhead and to improve the performance offered by compute-intensive tasks. Besides, the code is easier to understand than the old threaded version and the developers require less synchronization.
This new framework is very useful for compute-intensive tasks running on multicore CPUs.
There are many other features that will be available in JDK 7, like the new ParallelArray. However, I wanted to keep the focus on a short and simple introduction to the new fork-join framework.
Java is evolving. Thus, Java developers must also evolve to take advantage of these forthcoming features.
For more details, go here and watch the excellent slides of "Let's Resync. Concurrency Features in JDK 7", by Brian Goetz, Sr. Staff Engineer, Sun Microsystems.