java里面execute什么意思_Java线程池中submit()和execute之间的区别?
一:
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
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
