?
Solved

ThreadGroup active count really high for my servlet, why?

Posted on 2006-06-28
3
Medium Priority
?
222 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 300 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

864 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