aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2001-02-20 18:05:57 +0000
committerTom Tromey <tromey@gcc.gnu.org>2001-02-20 18:05:57 +0000
commit0cbd39801459319899e08e930f5257c2ced61ddb (patch)
treeeba0bc024ffe0227ffefba9daef7d35c9c8f9ae0 /libjava
parent20636516030126a3cbaca6ecfeb16dfdc2743b01 (diff)
downloadgcc-0cbd39801459319899e08e930f5257c2ced61ddb.zip
gcc-0cbd39801459319899e08e930f5257c2ced61ddb.tar.gz
gcc-0cbd39801459319899e08e930f5257c2ced61ddb.tar.bz2
ThreadGroup.java (activeCount): Only include threads which are alive.
* java/lang/ThreadGroup.java (activeCount): Only include threads which are alive. (enumerate): Likewise. From-SVN: r39922
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/lang/ThreadGroup.java23
2 files changed, 22 insertions, 7 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 2756994..f179ab0 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,9 @@
+2001-02-16 Tom Tromey <tromey@cygnus.com>
+
+ * java/lang/ThreadGroup.java (activeCount): Only include threads
+ which are alive.
+ (enumerate): Likewise.
+
2001-02-19 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Integer.java (getInteger): Return default argument if
diff --git a/libjava/java/lang/ThreadGroup.java b/libjava/java/lang/ThreadGroup.java
index cf1e717..e8b4446 100644
--- a/libjava/java/lang/ThreadGroup.java
+++ b/libjava/java/lang/ThreadGroup.java
@@ -1,5 +1,5 @@
/* java.lang.ThreadGroup
- Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -204,16 +204,21 @@ public class ThreadGroup
* @return the number of active threads in this ThreadGroup and
* its descendants.
* @specnote it isn't clear what the definition of an "Active" thread is.
- * Current JDKs regard all threads as active until they are
- * finished, regardless of whether the thread has been started
- * or not. We implement this behaviour.
- * There is open JDC bug, <A HREF="http://developer.java.sun.com/developer/bugParade/bugs/4089701.html">
+ * Current JDKs regard a thread as active if has been
+ * started and not finished. We implement this behaviour.
+ * There is a JDC bug, <A HREF="http://developer.java.sun.com/developer/bugParade/bugs/4089701.html">
* 4089701</A>, regarding this issue.
*
*/
public synchronized int activeCount()
{
- int total = threads.size();
+ int total = 0;
+ for (int i = 0; i < threads.size(); ++i)
+ {
+ if (((Thread) threads.elementAt(i)).isAlive ())
+ ++total;
+ }
+
for (int i=0; i < groups.size(); i++)
{
ThreadGroup g = (ThreadGroup) groups.elementAt(i);
@@ -274,7 +279,11 @@ public class ThreadGroup
{
Enumeration e = threads.elements();
while (e.hasMoreElements() && next_index < list.length)
- list[next_index++] = (Thread) e.nextElement();
+ {
+ Thread t = (Thread) e.nextElement();
+ if (t.isAlive ())
+ list[next_index++] = t;
+ }
if (recurse && next_index != list.length)
{
e = groups.elements();