0

以下是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

线程,由 Executor 实现决定。

Parameters:
    task - the runnable task
Throws:
    NullPointerException - if the task is null
    RejectedExecutionException - if the task cannot be scheduled for execution

ForkJoinPool 已经是 ExecutorService 的实现了?他们在说什么?我怎么知道这种方法的行为?

4

1 回答 1

2

I'm not quite sure what you are asking here, but yes ForkJoinPool is an implementation of ExecutorService. The execute(Runnable) method will schedule a task to be executed by the ForkJoinPool. This task will get executed when a worker thread in the pool is free to conduct such a task. It is essentially the same as submit(Runnable) except that it does not return a ForkJoinTask (In fact if you check the source code you will see that both methods do the same thing, except execute doesn't return the task it submits).

于 2013-07-26T13:18:33.247 回答