question about "active thread in ThreadGroup"

E

emily.ranyu

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top