Reputation: 462
Can a developer tell fork/join pool to create certain number of threads? If yes then is it guaranteed that those many number of threads will be created by pool?
Upvotes: 0
Views: 2659
Reputation: 539
basically a fork join pool is ThreadPool which works on work-stealing algorithm. There are api to specify parallelism (max number of active threads - (0-2^15-1))
Specifying parallelism doesn't mean pool will create those many threads at start, but it will create threads if required when work is submitted to pool.
Upvotes: 0
Reputation: 1225
Source : https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html
A ForkJoinPool is constructed with a given target parallelism level; by default, equal to the number of available processors. The pool attempts to maintain enough active (or available) threads by dynamically adding, suspending, or resuming internal worker threads, even if some tasks are stalled waiting to join others
Upvotes: 1