我有一组工作线程,我在其中为长时间运行的作业运行匿名类可运行文件。这些线程在响应返回后持续很长时间,但似乎创建这些 Runnables 的线程仍然存在,并且考虑在使用中。
为了实现的缘故,这里是代码......用更少的词。
@Path("/myawesomeApp")
public class TheThing {
static final TheWorkerPool pool = new TheWorkerPool();
static final HashMap<Integer,String> map = new ConcurrentHashMap<Integer,String>();
static int mapIdx = 0;
@Context
HttpServletContext context;
@POST
Integer doStuff() {
Integer thisVariable = mapIdx++;
pool.enqueue(new Runnable() {
public void run() {
map.put(thisVariable, OtherStuff.dothings());
}
});
}
}
他们每个人都坚持以下几点:
java.lang.Thread.State: RUNNABLE
at org.apache.tomcat.jni.Socket.recvbb(Native Method)
at org.apache.coyote.ajp.AjpAprProcessor.readt(AjpAprProcessor.java:1049)
at org.apache.coyote.ajp.AjpAprProcessor.readMessage(AjpAprProcessor.java:1140)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:368)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Thread.java:619)