Extensions to the concurrency framework
Doug Lea gave us a glimpse of upcoming additions to the Java 7 concurrency framework. The Fork/Join framework looks particularly interesting. Imagine a task you want to solve in pieces in parallel and then assemble the final result from the pieces' results. The Fork/Join framework is designed for just such tasks.
The pseudocode below shows how to use the Fork/Join framework to solve a problem that can be parallelized.
Result solve(Problem problem) {
if (problem is small)
directly solve problem
else {
split problem into independent parts
fork new subtasks to solve each part
join all subtasks
compose result from subresults
}
}While discussing the Fork/Join framework, Doug Lea talked about the performance gains on multicore systems, which will become increasingly common.
Big (32+) multicores will be coming out in volume during the lifetime of Java 7, and having this framework in place will allow people running them to get relatively simple speedups for computation-intensive tasks. Right now, forkjoin works best on machines like Sun Niagaras and Azuls, which are the only current processors of the form that will soon be common. It also works well on standard SMPs. In general, you don’t get many speedup benefits with less than 4 processors though — the main targets are in the dozens to hundreds of processors range.
Related articles
Related CZ Podcast episodes
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio