• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

counting running threads

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if it's not the right forum.

My question is, how do I count the number of running threads in server?

Some thoughts: Whenever a request comes from a browser (client), server creates a thread (or take one thread from thread pool?) & that thread executes (takes care of) that request, once response sent, thread gets over (or goes back in thread pool?).

Now if I increase a counter whenever a new thread is created by server (say in the beginning of service() method, though thread is already created by this time & thread itself is executing this service() method) and decrease it when response is sent to browser (in the very end of service() method), will this give me right number?

Any listener I can make use of? Or anything OOB available?

Thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Tomcat Management app can show you all of the request processing Thread in the Thread pool with their current state.

Since that is so useful I would expect similar tools for other servers.

Alternately you could create a request filter or create a modified service method.

Bill

 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic