Skip to content

Fork-Join Framework in JDK7

January 5, 2012

The Fork/Join library introduced in Java 7 extends the existing Java concurrency package with support for hardware parallelism, a key feature of multicore systems and also introduces work stealing algorithm. Oracle Doc

A common pitfall is to use synchronize and provide mutual exclusion over large pieces of code or even whole methods. While this approach leads to thread-safe code, it usually yields poor performance due to the limited parallelism that is induced by exclusion being in effect too long.

Fork/Join’s logic is as follows in crux:

  • separate (fork) each large task into smaller tasks
  • process each task in a separate thread (separating those into even smaller tasks if necessary)
  • join the results.

From → java

One Comment
  1. Thanks for the post, was an fascinating read. Curious as to how you came about that solution…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: