Heading of this article is deceptive, as both fork join and executives suffice different needs and they are meant to handle different kinds of parallel/concurrency tasks. But since in many scenarios we can
use them interchangeably, it is important to understand difference between them.
ForkJoin framework internally uses a special thread pool knows as ForkJoinPool, based on executorservice. But Fork Join pool has following distinctive properties.
1. It uses work stealing algorithm, hence no of idle workers are less and can be faster.
2. It manages the pool size dynamically
3. ForkJoin pool threads are daemon threads. Hence we do not need to explicitly shutdown them as we do in executorservice with "executorService.shutdown()".
ForkJoin pool are meant to handle a task that can be broken down into many smaller tasks and solve them recursively. ExecutorService is helpful for executing independent tasks .
use them interchangeably, it is important to understand difference between them.
ForkJoin framework internally uses a special thread pool knows as ForkJoinPool, based on executorservice. But Fork Join pool has following distinctive properties.
1. It uses work stealing algorithm, hence no of idle workers are less and can be faster.
2. It manages the pool size dynamically
3. ForkJoin pool threads are daemon threads. Hence we do not need to explicitly shutdown them as we do in executorservice with "executorService.shutdown()".
ForkJoin pool are meant to handle a task that can be broken down into many smaller tasks and solve them recursively. ExecutorService is helpful for executing independent tasks .
No comments:
Post a Comment