I program a C-S system. Jiver messager is used in server side and a app server(in Tomcat) is realized by Smack; the client is browser or handset.
now the system is runing. when the system run about 24 hours On a Debian Linux system, I found Tomcat(the web server) have more than 3000 threads. So I use jstack(java.sun.com) to see what happened in my system. the statistics data is as follow:
Thread information :number(thread count)
org.jivesoftware.smack.PacketReader.access$100(org.jivesoftware.smack.PacketRead er) @bci=1, line=43 (Interpreted frame) : 2700
java.net.SocketInputStream.socketRead0 : 92
org.jivesoftware.smack.PacketWriter.nextPacket() @bci=31, line=226 (Compiled frame) : 88
org.jivesoftware.smack.PacketWriter$KeepAliveTask.run() @bci=61, line=472 (Compiled frame) : 88
org.jivesoftware.smack.PacketWriter.processListeners() @bci=38, line=284 (Compiled frame) : 88
org.jivesoftware.smack.PacketReader.processListeners() @bci=160, line=257 (Interpreted frame) : 6
sun.jvm.hotspot.debugger.DebuggerException : 6
Total times: : 3068
The threads is accumulated by time until no response.
By the way, the total online users of my system is about 100 now, it is just a trial system.
the detail information about the first line(org.jivesoftware.smack.PacketReader.access$100(org.jivesoftware.smack.Pack etReader) @bci=1, line=43 (Interpreted frame) ) from jstack is like this:
Thread 9189: (state = BLOCKED)
-
java.lang.Object.wait(long) (Compiled frame; information may be imprecise)
-
java.lang.Object.wait() @bci=2, line=474 (Compiled frame)
-
org.jivesoftware.smack.PacketReader.access$100(org.jivesoftware.smack.PacketRea der) @bci=1, line=43 (Interpreted frame)
-
org.jivesoftware.smack.PacketReader$2.run() @bci=4, line=72 (Interpreted frame)
I read the source code of Smack in Packetwriter about 72th line and I really can’'t understand the code.
Can anyone tell me, why so man thread hang this, many many thanks.