0 Replies Latest reply on Dec 17, 2008 12:47 AM by Josh Britton

    Nervous Newbie Contemplates Growing Pile of Threads

    Josh Britton Newbie

      I am an ejb/Jboss newbie with an app that runs on a JBoss server. Clients communicate with the server app using both jms and rmi.

      I was debugging on the server side today (using eclipse) when I noticed that a client sending a message to a queue on the server caused odd thread behaviors: a group of several new threads suddenly appeared on the server, all 'waiting.' As the client sent more messages, more threads appeared, 'waiting'. Why are they waiting? The MDB that handles the messages only needs one thread, which should finish executing rapidly. When I tested with three clients, each sending messages every five seconds, I reached more than 20 new threads before a sort of 'equilibrium' was reached, with old threads disappearing as new threads appeared.

      Am I doing something wrong? Could I be inadvertently acquiring a lock that is blocking these surplus threads from expiring? Is there some way to avoid such a rapid accumulation of threads per client message? I hope to someday have hundreds of clients, all sending messages every few seconds, and it seems that so many threads could lead to memory and performance issues.

      The thread names include 'WorkManager' or 'JMSThread' Here is a sample WorkManager stack as it waits:

      Thread: WorkManager(2)-15 : priority:5, demon:true, threadId:138, threadState:TIMED_WAITING, lockName:java.lang.Object@9fbd73

      java.lang.Object.wait(Native Method)
      EDU.oswego.cs.dl.util.concurrent.BoundedLinkedQueue.poll(BoundedLinkedQueue.java:253)
      EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:736)
      org.jboss.util.threadpool.MinPooledExecutor.getTask(MinPooledExecutor.java:106)
      EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:760)
      java.lang.Thread.run(Thread.java:619)

      Thanks in advance for any pointers!