In recent years, the multicore processors are commonplace and are used everywhere, so a new trend has emerged in the field of computing, a concept called Parallel Processing or Parallel Programming. Parallel Programming is the set of methods or techniques which are used to take advantages of the computers that contain two or more processors (also called multicore processors), to speed up the performance of applications.
Prior to parallel programming, threads were being created to make concurrent programs, but threads were not actually being executed simultaneously (at the same time) because of the single-core processors, and they used to share CPU-time, to utilize the idle CPU time. But in parallel programming, two or more threads can actually execute simultaneously because of the multi-core processors.
See The Basics Of Multithreading In Java
Java has defined many core features (classes and interfaces) in its concurrency (or multithreading) API in JDK 5, which were required by the programmers for many years to make efficient concurrent programs. Features range from Synchronizers (Semaphores, CountDownLatch, CyclicBarrier, Exchanger, Phaser) to Executors and locks etc. Java has added a new feature in concurrency API in JDK 7 and further enhanced it in JDK 8, which is Fork/Join Framework to apply parallel programming techniques in the programs.
Fork/Join Framework enhances multithreading technique in two ways: 1) It simplifies the creation and use of threads, 2) It automatically makes use of multiple processors. Means, it enables the applications (programs) to make the best use of available processors. As a result, two or more portions of the program run simultaneously in different available processors, which significantly increases the performance of the applications, specifically in operations like sorting, transforming and searching in large data, which requires the fast and efficient response to the users.
Fork/Join Framework is packaged in java.util.concurrent. There are four classes at the core of the Fork/Join Framework:
- Fork/JoinTask
: An abstract class which defines a task. - ForkJoinPool: This class manages the execution of ForkJoinTasks (class).
- RecursiveActions: It is a subclass of ForkJoinTask
used for tasks that do not return values. - RecursiveTask
: It is also a subclass of ForkJoinTask used for tasks that return values.
Comments
Post a Comment