aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java')
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
index 31e9e27..6115c53 100644
--- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
+++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
@@ -42,10 +42,24 @@ class PluginMessageHandlerWorker extends Thread {
private boolean free = true;
private final boolean isPriorityWorker;
private final int id;
- private String message;
+ private volatile String message;
private PluginStreamHandler streamHandler;
private PluginMessageConsumer consumer;
+ public synchronized void notifyHasWork() {
+ notifyAll();
+ }
+
+ 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();
+ }
+ }
+
public PluginMessageHandlerWorker(
PluginMessageConsumer consumer,
PluginStreamHandler streamHandler, int id,
@@ -93,16 +107,10 @@ class PluginMessageHandlerWorker extends Thread {
free();
} else {
+ waitForWork();
- // Sleep when there is nothing to do
- try {
- Thread.sleep(Integer.MAX_VALUE);
- PluginDebug.debug("Consumer thread ", id, " sleeping...");
- } catch (InterruptedException ie) {
- PluginDebug.debug("Consumer thread ", id, " woken...");
- // nothing.. someone woke us up, see if there
- // is work to do
- }
+ // Someone woke us up, see if there is work to do
+ PluginDebug.debug("Consumer thread ", id, " woken...");
}
}
}
@@ -120,9 +128,6 @@ class PluginMessageHandlerWorker extends Thread {
public void free() {
synchronized (this) {
this.free = true;
-
- // Signal the consumer that we are done in case it was waiting
- consumer.notifyWorkerIsFree(this);
}
}