Improving performance of a application and effective usage of available hardware are the key aspects which we need to consider while building efficient enterprise applications. Performance of an application can be improved by making it to avail the full advantages of underlying hardware efficiently.

This can be achieved by writing concurrency-enabled programs which improves program throughput that in turn improves performance.
Parallelism or prallelization is a programming technique in which a CPU intensive task can be divided in to independent tasks which can be solved by executing them in parallel.
Java 7 has introduced a key concurrency feature "Fork/Join" framework under JSR 166y which implements ExecutorService interface.
Fork/Join approach is different from other algorithms as Fork/Join tasks will subdivide themselves into smaller tasks only if necessary.

FJ framework uses thread pools which can be sized appropriately to the number of available processors which reduces the swapping overhead.
Each worker thread maintains runnable tasks in its own scheduling double ended queues i.e,deques. The subtasks generated in a running task by a given worker thread are pushed on to that workers own deque and executes by popping tasks in LIFO manner.

To optimize the performance FJ uses light weight scheduling technique called "Work-Stealing" mechanism which means if
a worker thread has no work it attempts to take a task from another randomly chosen slower-executing worker thread's queue in FIFO manner. In essence,it uses LIFO to process its own tasks and FIFO to poach the work from other worker thread so that it reduces contention of threads.
When a worker thread encounters a join operation, it processes all other available tasks until the target task is noticed to have completed.
When a worker thread has no work and fails to steal any from other worker threads,it backs off and tries again later unless all other workers are known to be similarly idle.

To reduce the contention by repeated steals,the thread which failed steal reduces its priority before attempting additional steals and also
yields between attempts, and registers itself as inactive in its FJTaskRunnerGroup.If all other worker threads becomes inactive,they all block waiting for additional main tasks otherwise
after a certain number of additional retries worker threads sleep rather than yield between attempts.

In the subsequent posts I will discuss the key features of Fork/Join in detail with sample examples.