1.1 --- a/openide.util/src/org/openide/util/RequestProcessor.java Fri Sep 18 15:49:41 2009 +0200
1.2 +++ b/openide.util/src/org/openide/util/RequestProcessor.java Wed Sep 23 13:31:43 2009 +0200
1.3 @@ -126,10 +126,10 @@
1.4 // 50: a conservative value, just for case of misuse
1.5
1.6 /** the static instance for users that do not want to have own processor */
1.7 - private static RequestProcessor UNLIMITED = new RequestProcessor("Default RequestProcessor", 50); // NOI18N
1.8 + private static final RequestProcessor UNLIMITED = new RequestProcessor("Default RequestProcessor", 50); // NOI18N
1.9
1.10 /** A shared timer used to pass timeouted tasks to pending queue */
1.11 - private static final Timer starterThread = new Timer(true);
1.12 + private static Timer starterThread = new Timer(true);
1.13
1.14 /** logger */
1.15 private static Logger logger;
1.16 @@ -455,7 +455,7 @@
1.17 /** Logger for the error manager.
1.18 */
1.19 static Logger logger() {
1.20 - synchronized (starterThread) {
1.21 + synchronized (UNLIMITED) {
1.22 if (logger == null) {
1.23 logger = Logger.getLogger("org.openide.util.RequestProcessor"); // NOI18N
1.24 }
1.25 @@ -661,7 +661,21 @@
1.26 if (delay == 0) { // Place it to pending queue immediatelly
1.27 enqueue(localItem);
1.28 } else { // Post the starter
1.29 - starterThread.schedule(new EnqueueTask(localItem), delay);
1.30 + while (true) {
1.31 + Timer timer = starterThread;
1.32 + try {
1.33 + timer.schedule(new EnqueueTask(localItem), delay);
1.34 + break;
1.35 + } catch (IllegalStateException e) {
1.36 + logger().info(e.toString());
1.37 + // starterThread cancelled, create new one and try to schedule again
1.38 + synchronized (UNLIMITED) {
1.39 + if (timer == starterThread) {
1.40 + starterThread = new Timer(true);
1.41 + }
1.42 + }
1.43 + }
1.44 + }
1.45 }
1.46 }
1.47