Questions tagged [forkjoinpool]

Use this tag for questions related to ForkJoinPool, a Java class, which provides the entry point for submissions from non-ForkJoinTask clients, as well as management and monitoring operations.

If you use , then you may want to use too.

250 questions
50
votes
5 answers

In which thread do CompletableFuture's completion handlers execute?

I have a question about CompletableFuture method: public CompletableFuture thenApply(Function fn) The thing is the JavaDoc says just this: Returns a new CompletionStage that, when this stage completes normally, is…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
44
votes
3 answers

Detailed difference between Java8 ForkJoinPool and Executors.newWorkStealingPool?

What is the low-level difference among using: ForkJoinPool = new ForkJoinPool(X); and ExecutorService ex = Executors.newWorkStealingPool(X); Where X is the desired level of parallelism, i.e. threads running. According to the docs, I found them…
35
votes
4 answers

What's the advantage of a Java-5 ThreadPoolExecutor over a Java-7 ForkJoinPool?

Java 5 has introduced support for asynchronous task execution by a thread pool in the form of the Executor framework, whose heart is the thread pool implemented by java.util.concurrent.ThreadPoolExecutor. Java 7 has added an alternative thread pool…
28
votes
3 answers

Java support for three different concurrency models

I am going through different concurrency model in multi-threading environment (http://tutorials.jenkov.com/java-concurrency/concurrency-models.html) The article highlights about three concurrency models: Parallel Workers The first concurrency…
Ravindra babu
  • 37,698
  • 11
  • 250
  • 211
28
votes
1 answer

Java ForkJoinPool with non-recursive tasks, does work-stealing work?

I want to submit Runnable tasks into ForkJoinPool via a method: forkJoinPool.submit(Runnable task) Note, I use JDK 7. Under the hood, they are transformed into ForkJoinTask objects. I know that ForkJoinPool is efficient when a task is split into…
Ivan Voroshilin
  • 5,233
  • 3
  • 32
  • 61
27
votes
3 answers

Where does official documentation say that Java's parallel stream operations use fork/join?

Here's my understanding of the Stream framework of Java 8: Something creates a source Stream The implementation is responsible for providing a BaseStream#parallel() method, which in turns returns a Stream that can run it's operations in…
Gima
  • 1,892
  • 19
  • 23
22
votes
2 answers

What is ForkJoinPool Async mode

What does Async mode of ForkJoinPool mean? Javadoc mentions that it makes queues (is it per-thread queue?) FIFO instead of LIFO. What does it mean in practice?
Primk
  • 481
  • 1
  • 5
  • 10
19
votes
2 answers

Calling sequential on parallel stream makes all previous operations sequential

I've got a significant set of data, and want to call slow, but clean method and than call fast method with side effects on result of the first one. I'm not interested in intermediate results, so i would like not to collect them. Obvious solution is…
the20login
  • 193
  • 1
  • 5
17
votes
1 answer

Java 8 parallel stream and ThreadLocal

I am trying to figure out how can I copy a ThreadLocal value in Java 8 parallel stream. So if we consider this: public class ThreadLocalTest { public static void main(String[] args) { ThreadContext.set("MAIN"); …
Anatoli Radulov
  • 556
  • 6
  • 12
16
votes
2 answers

ForkJoinTask vs CompletableFuture

In Java 8 there are two ways of starting asynchronous computations - CompletableFuture and ForkJoinTask. They both seem fairly similar - the inner classes of CompletableFuture even extend ForkJoinTask. Is there a reason to use one over the…
thecoop
  • 45,220
  • 19
  • 132
  • 189
12
votes
2 answers

How Akka benefits from ForkJoinPool?

Akka docs states that default dispatcher is a fork-join-executor because it "gives excellent performance in most cases". I'm wondering why is it? From ForkJoinPool A ForkJoinPool differs from other kinds of ExecutorService mainly by virtue of…
gabrielgiussi
  • 9,245
  • 7
  • 41
  • 71
12
votes
1 answer

How to configure and tune Akka Dispatchers

I'm looking over the documentation here: http://doc.akka.io/docs/akka/2.3.3/java/dispatchers.html We're using Akka in such a way where we have two separate dispatchers (default fork-join executors) for different actors. We're now running into some…
HiChews123
  • 1,598
  • 4
  • 20
  • 39
11
votes
1 answer

ForkJoinPool scheduling vs ExecutorService

I'm slightly confused by the internal scheduling mechanism of the ExecutorService and the ForkJoinPool. I understand the ExecutorService scheduling is done this way. A bunch of tasks are queued. Once a thread is available it will handle the first…
teivah
  • 123
  • 1
  • 6
11
votes
1 answer

Java ForkJoinPool - order of tasks in queues

I would like to understand the order in which tasks are processed in Java fork-join pool. So far, the only relevant information I've found in the docs is about a parameter called the "asyncMode", which is "true if this pool uses local…
Kenny Wong
  • 384
  • 3
  • 20
11
votes
2 answers

Default ForkJoinPool executor taking long time

I am working with the CompletableFuture for async execution of a stream generated from a list source. so i am testing the overloaded method i.e. "supplyAsync" of CompletableFuture in which one method takes only single supplier parameter and other…
1
2 3
16 17