I wrote servlet with smack to connect jabber server and found that the active thread number kept increasing quickly. I wonder why there were so many threads that couldn’‘t stop running that made the system’'s tcp connection almost disfunctioned?
When the user logs in the application, my program just creates a XMPPConnection and add listeners,including ConnectionListener and PacketListener as well as RosterListener, then saves the connection and listeners’’ objects in the application scope memory. When the user logs out, the program will close the xmpp connection. But why still many of the threads remain? about 700 unexpected threads in day referenced by the following lines!
please help me to solve the problem, thank you!
visit(tcp-server) threadName[146]: Thread-510
visit(tcp-server) threadName[147]: Smack Packet Reader
visit(tcp-server) threadName[148]: Smack Listener Processor
visit(tcp-server) threadName[149]: Smack Packet Writer
visit(tcp-server) threadName[150]: Smack Writer Listener Processor
visit(tcp-server) threadName[151]: Thread-520
visit(tcp-server) threadName[152]: Smack Packet Reader
visit(tcp-server) threadName[153]: Smack Listener Processor
visit(tcp-server) threadName[154]: Smack Packet Writer
visit(tcp-server) threadName[155]: Smack Writer Listener Processor
visit(tcp-server) threadName[156]: Thread-535
visit(tcp-server) threadName[157]: Smack Packet Reader
visit(tcp-server) threadName[158]: Smack Listener Processor
visit(tcp-server) threadName[159]: Smack Packet Writer
visit(tcp-server) threadName[160]: Smack Writer ListenerProces
…
…
…