Solved

ThreadGroup active count really high for my servlet, why?

Posted on 2006-06-28
3
213 Views
Last Modified: 2013-11-24
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??
0
Comment
Question by:arctanx
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17005754
container will create new thread to handle requests, and it may also be using a thread pool.
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17006356
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.
0
 
LVL 35

Accepted Solution

by:
girionis earned 100 total points
ID: 17007635
Most (if not all) of the containers use a thread pool. for more info have a look here: http://www.javaworld.com/javaworld/jw-06-2004/jw-0628-performance-p2.html
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question