Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Concurrent Patterns and Best Practices

You're reading from   Concurrent Patterns and Best Practices Build scalable apps in Java with multithreading, synchronization and functional programming patterns

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788627900
Length 264 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Atul S. Khot Atul S. Khot
Author Profile Icon Atul S. Khot
Atul S. Khot
Arrow right icon
View More author details
Toc

The fork-join pool

Java 7 introduced a specialized executor service, namely, the fork-join API. It dynamically manages the number of threads, based on the available processors, and other parameters such as the number of concurrent tasks. It also employs an important pattern, work stealing—we will soon discuss this.

Egrep – simple version

Let's see the fork-join API in action. We will look at two examples to understand how the API works. The idea is to find a word in a text file. The driver class is EgrepWord:

public class EgrepWord {
private final static ForkJoinPool forkJoinPool = new ForkJoinPool();

The principal theme in the fork-join API is a recursive task. The following class extends...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime