top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How fork join comes in existence?

+1 vote
222 views
How fork join comes in existence?
posted Apr 17, 2015 by Dominic

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Java’s most attractive part is it makes things easier and easier.for doing things faster java has given us concurrency concept but dealing with concurrency is not easy because we have to deal with thread synchronization and shared data. When we have to work with small piece of code it is easy to handle synchronization and atomicity, but it becomes for complex when code base and number of threads increased, its really challenging where several threads are working together to accomplish a large task so again java has tried to make things easy and simplifies this concurrency using Executors and Thread Queue.

When we compare Executors with old Thread it has made management of concurrent task very easy and it work on divide and conquer algorithm and create sub-tasks and communicate with each other to complete.But The problem with the executors framework is that a Callable is free to submit a new sub-task to its executor and wait for its result in a synchronous or asynchronous fashion. The issue is that of parallelism: When a Callable waits for the result of another Callable, it is put in a waiting state, and thus wasting an opportunity to handle another Callable queued for execution.

To solve this issue java 7 has given the concept of parallelism.New fork-join framework has been added in java.util.concurrent package.New fork-join executor framework has been created which is responsible for creating one new task object which is again responsible for creating new sub-task object and waiting for sub-task to be completed.internally it maintains a thread pool and executor assign pending task to this thread pool to complete when one task is waiting for another task to complete. whole Idea of fork-join framework is to leverage multiple processors of advanced machine.

enter image description here

answer Apr 20, 2015 by Karthick.c
...