From f9d44b00b686b9973139863c7d6472c2b7a11eb3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 13 Nov 2001 23:09:23 +0000 Subject: re PR libgcj/4859 (java.util.Timer class throw IllegalStateException on cancel()) 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/java/util/Timer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libjava/java/util') diff --git a/libjava/java/util/Timer.java b/libjava/java/util/Timer.java index 32c0bea..2c7197f 100644 --- a/libjava/java/util/Timer.java +++ b/libjava/java/util/Timer.java @@ -285,6 +285,14 @@ public class Timer this.notify(); } + /** + * This method returns true 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) { -- cgit v1.1