Solved

ThreadGroup active count really high for my servlet, why?

Posted on 2006-06-28
3
209 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now