Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

question about "active thread in ThreadGroup"

Thread view: 
emily.ranyu@gmail.com - 05 Jun 2006 03:46 GMT
here is the api doc the threadgroup:
public int activeCount()
Returns an estimate of the number of active threads in this thread
group.

public int enumerate(Thread[] list)
Copies into the specified array every active thread in this thread
group and its subgroups. ... An application should use the activeCount
method to get an estimate of how big the array should be. ...

they all use the terminology "active thread"! BUT they operate in
different ways! in "activeCount()" it just returns the private variable
"nthreads" and "nthreads" increased when add method was invoked.
in "enumerate()" it will go through the thread list and check whether
it is alive.

that means, you will got some number after adding the thread into the
threadgroup without starting it, but it will tell you that there is NO
active thread in specified threadgroup when you go through the thread
list generated by "enumerate()"

is it ambiguous? is it a bug? or...

anybody can make it clear for me? thanks a lot!
EJP - 05 Jun 2006 06:06 GMT
> is it ambiguous? is it a bug? or...

No. ThreadGroup.activeCount() is just an estimate, as it says.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.