一:
submit()方法,可以提供Future < T > 类型的返回值。
executor()方法,无返回值。
execute无返回值public void execute(Runnable command) {
if (command == null)
throw new NullPointerException();//抛掉异常
int c = ctl.get();
if (workerCountOf(c) < corePoolSize) {
if (addWorker(command, true))
return;
c = ctl.get();
}
if (isRunning(c) && workQueue.offer(command)) {
int recheck = ctl.get();
if (! isRunning(recheck) && remove(command))
reject(command);
else if (workerCountOf(recheck) == 0)
addWorker(null, false);
}
else if (!addWorker(command, false))
reject(command);
}
submit有Future返回值 :/**
* @throws RejectedExecutionException {@inheritDoc}
* @throws NullPointerExcepti