ForkJoinPool.commonPool() 的线程拒绝策略是什么?

What is the thread rejection policy of ForkJoinPool.commonPool()?

我的代码中有 parallelStreams(),它使用的是 ForkJoinPool

一个线程池执行器有 4 个预定义的处理程序策略,我想知道它在公共池中默认使用哪个(如果有的话)。我在文档中找不到它。

In the default ThreadPoolExecutor.AbortPolicy, the handler throws a runtime RejectedExecutionException upon rejection.

In ThreadPoolExecutor.CallerRunsPolicy, the thread that invokes execute itself runs the task. This provides a simple feedback control mechanism that will slow down the rate that new tasks are submitted.

In ThreadPoolExecutor.DiscardPolicy, a task that cannot be executed is simply dropped.

In ThreadPoolExecutor.DiscardOldestPolicy, if the executor is not shut down, the task at the head of the work queue is dropped, and then execution is retried (which can fail again, causing this to be repeated.)

来自 Oracle's documentation.

来自 ForkJoinPool 的 javadoc

This implementation rejects submitted tasks (that is, by throwing RejectedExecutionException) only when the pool is shut down or internal resources have been exhausted.

这与 ThreadPoolExecutor.AbortPolicy 的行为相同。