Tomcat 中Executor?

千锋教育

1、Tomcat希望将Executor也纳入Lifecycle生命周期管理,所以让它实现了Lifecycle接口;


2、引入超时机制:也就是说当work queue满时,会等待指定的时间,如果超时将抛出RejectedExecutionException,所以这里增加了一个void execute(Runnable command, long timeout, TimeUnit unit)方法; 其实本质上,它构造了JUC中ThreadPoolExecutor,通过它调用ThreadPoolExecutor的void execute(Runnable command, long timeout, TimeUnit unit)方法。