这是 API 的内容对此说道:
public void execute(Runnable task) Description copied from interface: Executor Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling
thread, at the discretion of the Executor implementation.
Parameters: task - the runnable task Throws: NullPointerException - if the task is null RejectedExecutionException - if the task cannot be scheduled for execution
ForkJoinPool 已经是 ExecutorService 的实现?他们在说什么?我如何知道这种方法的行为?
最佳答案
我不太确定你在这里问什么,但是ForkJoinPool
是ExecutorService
的实现。 execute(Runnable)
方法将安排由 ForkJoinPool
执行的任务。当池中的工作线程可以自由执行此类任务时,将执行此任务。它本质上与 submit(Runnable)
相同,只是它不返回 ForkJoinTask
(事实上,如果您检查源代码,您会发现这两种方法执行相同的操作)事情,除了 execute
不返回它提交的任务)。
关于java - ForkJoinPool 类的 execute() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17881715/