diff options
Diffstat (limited to 'plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java')
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java index ec0a6e7..a5db7be 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java +++ b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java @@ -116,17 +116,13 @@ class PluginMessageConsumer { return null; } - public void notifyWorkerIsFree(PluginMessageHandlerWorker worker) { - consumerThread.interrupt(); - } - public void queue(String message) { synchronized (readQueue) { readQueue.addLast(message); } // Wake that lazy consumer thread - consumerThread.interrupt(); + consumerThread.notifyHasWork(); } protected class ConsumerThread extends Thread { @@ -135,6 +131,22 @@ class PluginMessageConsumer { super("PluginMessageConsumer.ConsumerThread"); } + // Notify that either work is ready to do, or a worker is available + public synchronized void notifyHasWork() { + notifyAll(); + } + + // Wait a bit until either work is ready to do, or a worker is available + public synchronized void waitForWork() { + try { + // Do not wait indefinitely to avoid the potential of deadlock + wait(1000); + } catch (InterruptedException e) { + // Should not typically occur + e.printStackTrace(); + } + } + /** * Scans the readQueue for priority messages and brings them to the front */ @@ -194,13 +206,10 @@ class PluginMessageConsumer { } worker.setmessage(message); - worker.interrupt(); + worker.notifyHasWork(); } else { - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - } + waitForWork(); } } } |