How can I know how many thread does a ForkJoinPool
have? Let's say the ThreadForkJoinPool
implementation.
I have a dual core.
Second quick question: Does synchronization (locks) work also with parallelism? Thanks in advance.
How can I know how many thread does a ForkJoinPool
have? Let's say the ThreadForkJoinPool
implementation.
I have a dual core.
Second quick question: Does synchronization (locks) work also with parallelism? Thanks in advance.
根据 Javadoc,无论您使用多少创建它。如果您使用默认构造函数:
public ForkJoinPool()
创建一个并行度等于 Runtime.availableProcessors() 的 ForkJoinPool,使用默认线程工厂、无 UncaughtExceptionHandler 和非异步 LIFO 处理模式。
如果您使用int
构造函数:
public ForkJoinPool(int parallelism)
创建一个具有指定并行度级别、默认线程工厂、无 UncaughtExceptionHandler 和非异步 LIFO 处理模式的 ForkJoinPool。
请在提问前阅读文档,并且一次只问一个问题。