re PR libgcj/4859 (java.util.Timer class throw IllegalStateException on cancel())
authorTom Tromey <tromey@redhat.com>
Tue, 13 Nov 2001 23:09:23 +0000 (23:09 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 13 Nov 2001 23:09:23 +0000 (23:09 +0000)
Fix for PR libgcj/4859:
* java/util/Timer.java (TaskQueue.isStopped): New method.
(Scheduler.run): Don't re-schedule task if queue has been
stopped.

From-SVN: r46994

libjava/ChangeLog
libjava/java/util/Timer.java

index 9dfcd7b32e9febe147c60b3a26b26a2118a4b535..fd3e7bab640b118ef9a9e5c522fd55226717b7bb 100644 (file)
@@ -1,3 +1,10 @@
+2001-11-13  Tom Tromey  <tromey@redhat.com>
+
+       Fix for PR libgcj/4859:
+       * java/util/Timer.java (TaskQueue.isStopped): New method.
+       (Scheduler.run): Don't re-schedule task if queue has been
+       stopped.
+
 2001-11-07  Tom Tromey  <tromey@redhat.com>
 
        * Makefile.in: Rebuilt.
index 32c0bea3b3f7dec1d985f4497ed971cd5c1febe8..2c7197f2dbec202277413b6fc3997391dc0cfa03 100644 (file)
@@ -285,6 +285,14 @@ public class Timer
       this.notify();
     }
 
+    /**
+     * This method returns <code>true</code> if the queue has been
+     * stopped.
+     */
+    public synchronized boolean isStopped ()
+    {
+      return this.heap == null;
+    }
   }                            // TaskQueue
 
   /**
@@ -337,8 +345,9 @@ public class Timer
                }
            }
 
-         // Calculate next time and possibly re-enqueue
-         if (task.scheduled >= 0)
+         // Calculate next time and possibly re-enqueue.
+         // Don't bother re-scheduling if the queue has been stopped.
+         if (! queue.isStopped () && task.scheduled >= 0)
            {
              if (task.fixed)
                {