我有一组工作线程,我为长时间运行的作业运行匿名类runnables。这些线程在返回响应后持续很长时间,但似乎创建这些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)
答案 0 :(得分:0)
我想在这种情况下根本不会调用TheThing的代码。 见AjpAprProcessor's source。它一直在阅读一些必需的http请求标题。
因此,请检查ajp配置,并确保客户端正确发送http请求。
尝试在apache端启用日志记录。