aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-03-28 12:38:52 -0400
committerAdam Domurad <[email protected]>2013-03-28 12:38:52 -0400
commit6bc87a67d88072fa2d701cf4e6a700893ee81e00 (patch)
treeb0514cba9f54833955573a748be39369f5c077c9 /plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
parent8d2d31514295a2d0eff5971887246f6d4211fc6d (diff)
Don't interrupt message handling threads
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);
}
}