Link to home
Start Free TrialLog in
Avatar of arctanx
arctanx

asked on

ThreadGroup active count really high for my servlet, why?

I've got a section of code:

ThreadGroup tg = Thread.currentThread().getThreadGroup();

When I get a sys out for this when my class is running as a service, in the main() method, it returns 1 or 2, as it should.

When I run the SAME CODE except now it's running as a servlet called from the init method it's returning 35, sometimes 40!!  It's different everytime.

Why??
Avatar of Mick Barry
Mick Barry
Flag of Australia image

container will create new thread to handle requests, and it may also be using a thread pool.
Avatar of Ajay-Singh
Ajay-Singh

Tomcat (or any other web container) uses threadpool to handle requests of the client. These threads belongs to same threadgroup which is different from main threadgroup.
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial