最佳答案
我在 tomcat 服务器(+ liferay)上得到了这个异常
java.util.concurrent.RejectedExecutionException
我的课是这样的:
public class SingleExecutor extends ThreadPoolExecutor {
public SingleExecutor(){
super(1, 1,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
}
@Override
public void execute(Runnable command) {
if(command instanceof AccessLogInsert){
AccessLogInsert ali = (AccessLogInsert)command;
ali.setConn(conn);
ali.setPs(ps);
}
super.execute(command);
}
}
我在 super.execute(command);
行得到这个异常
当队列已满但 LinkedBlockingQueue
大小为2 ^ 31时,可能会发生此错误,并且我确信没有那么多命令在等待。
一开始一切都很稳定,但在我重新部署一场战争之后,它就开始发生了。这个类不是 war 的一部分,而是在 tomcat/lib 中的一个 jar 中。
你知道为什么会发生这种事,以及如何解决吗?