我将 Tomcat 7.0.42 用于使用 websockets 的应用程序。如果我的应用程序负载很重,我会在一些使用 websockets 的线程中遇到死锁。
由于找不到修复程序,是否有解决此问题的方法?
我使用 Atmpshere 2.0RC3 runtime-native。
这是我的线程转储的相关部分。我使用 Samurai 来检测死锁的线程。
"Atmosphere-Shared-AsyncOp-267" daemon prio=10 tid=0x00007efed8118000 nid=0x2eb5 waiting for monitor entry [0x00007efe798ca000] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.catalina.websocket.WsOutbound.writeTextMessage(WsOutbound.java:165) - waiting to lock <0x00000005ef4c6988> (a org.apache.catalina.websocket.WsOutbound)
at org.atmosphere.container.version.TomcatWebSocket.write(TomcatWebSocket.java:49)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:199)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:168)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:40)
at org.atmosphere.cpr.AtmosphereResponse$2.write(AtmosphereResponse.java:574)
at org.atmosphere.handler.AbstractReflectorAtmosphereHandler.onStateChange(AbstractReflectorAtmosphereHandler.java:169)
at org.atmosphere.cpr.DefaultBroadcaster.invokeOnStateChange(DefaultBroadcaster.java:1027)
at org.atmosphere.cpr.DefaultBroadcaster.prepareInvokeOnStateChange(DefaultBroadcaster.java:1047)
at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:921)
at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:580) - locked <
0x00000005ef4b77f8> (a org.atmosphere.cpr.AtmosphereResourceImpl)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
"Atmosphere-Scheduler-2" daemon prio=10 tid=0x00007efee9c77800 nid=0x257d waiting for monitor entry [0x00007efe831ef000] java.lang.Thread.State: BLOCKED (on object monitor)
at org.atmosphere.cpr.AsynchronousProcessor.completeLifecycle(AsynchronousProcessor.java:476) - waiting to lock <0x00000005ef4b77f8> (a org.atmosphere.cpr.AtmosphereResourceImpl)
at org.atmosphere.cpr.AsynchronousProcessor.timedout(AsynchronousProcessor.java:437)
at org.atmosphere.cpr.AsynchronousProcessor$AsynchronousProcessorHook.timedOut(AsynchronousProcessor.java:633)
at org.atmosphere.websocket.DefaultWebSocketProcessor.close(DefaultWebSocketProcessor.java:483)
at org.atmosphere.container.TomcatWebSocketHandler.onClose(TomcatWebSocketHandler.java:80)
at org.apache.catalina.websocket.StreamInbound.doOnClose(StreamInbound.java:222)
at org.apache.catalina.websocket.WsOutbound.doWriteBytes(WsOutbound.java:423)
at org.apache.catalina.websocket.WsOutbound.doWriteText(WsOutbound.java:442)
at org.apache.catalina.websocket.WsOutbound.writeTextMessage(WsOutbound.java:174) - locked <
0x00000005ef4c6988> (a org.apache.catalina.websocket.WsOutbound)
at org.atmosphere.container.version.TomcatWebSocket.write(TomcatWebSocket.java:49)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:199)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:168)
at org.atmosphere.websocket.WebSocket.write(WebSocket.java:40)
at org.atmosphere.cpr.AtmosphereResponse$2.write(AtmosphereResponse.java:574)
at org.atmosphere.cpr.AtmosphereResponse.write(AtmosphereResponse.java:992)
at org.atmosphere.interceptor.HeartbeatInterceptor$1$1.call(HeartbeatInterceptor.java:104) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)