aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
diff options
context:
space:
mode:
authorDeepak Bhole <[email protected]>2010-12-06 15:34:01 -0500
committerDeepak Bhole <[email protected]>2010-12-06 15:34:01 -0500
commit6ca1a9a369b10703da9af8f8a1ced0f3b02ae5c2 (patch)
tree568f8e454db94fa8abc896b46ce8cac7a9f3b74d /plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
parent0d66adf24179c33bbdccaacc10d4c8a5f5e2cd54 (diff)
Fixed indentation and spacing for all .java files.
Added a new .settings directory which contains Eclipse preferences for code style.
Diffstat (limited to 'plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java')
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java204
1 files changed, 100 insertions, 104 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
index 30714c4..91e3746 100644
--- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
+++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
@@ -35,113 +35,109 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package sun.applet;
-
class PluginMessageHandlerWorker extends Thread {
- private boolean free = true;
- private boolean isPriorityWorker = false;
- private int id;
- private String message = null;
- private SecurityManager sm;
- PluginStreamHandler streamHandler = null;
- PluginMessageConsumer consumer = null;
-
- public PluginMessageHandlerWorker(
- PluginMessageConsumer consumer,
- PluginStreamHandler streamHandler, int id,
- SecurityManager sm, boolean isPriorityWorker) {
-
- this.id = id;
- this.streamHandler = streamHandler;
- this.sm = sm;
- this.isPriorityWorker = isPriorityWorker;
- this.consumer = consumer;
-
- PluginDebug.debug("Worker " + this.id + " (priority=" + isPriorityWorker + ") created.");
- }
-
- public void setmessage(String message) {
- this.message = message;
- }
-
- public void run() {
- while (true) {
-
- if (message != null) {
-
- PluginDebug.debug("Consumer (priority=" + isPriorityWorker + ") thread " + id + " consuming " + message);
-
- // ideally, whoever returns things object should mark it
- // busy first, but just in case..
- busy();
-
- try {
- streamHandler.handleMessage(message);
- } catch (PluginException pe) {
- /*
- catch the exception and DO NOTHING. The plugin should take over after
- this error and let the user know. We don't quit because otherwise the
- exception will spread to the rest of the applets which is a no-no
- */
- }
-
- this.message = null;
-
- PluginDebug.debug("Consumption (priority=" + isPriorityWorker + ") completed by consumer thread " + id);
-
- // mark ourselves free again
- free();
-
- } else {
-
- // 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
- }
- }
- }
- }
-
-
-
- public int getWorkerId() {
- return id;
- }
-
- public void busy() {
- synchronized (this) {
- this.free = false;
+ private boolean free = true;
+ private boolean isPriorityWorker = false;
+ private int id;
+ private String message = null;
+ private SecurityManager sm;
+ PluginStreamHandler streamHandler = null;
+ PluginMessageConsumer consumer = null;
+
+ public PluginMessageHandlerWorker(
+ PluginMessageConsumer consumer,
+ PluginStreamHandler streamHandler, int id,
+ SecurityManager sm, boolean isPriorityWorker) {
+
+ this.id = id;
+ this.streamHandler = streamHandler;
+ this.sm = sm;
+ this.isPriorityWorker = isPriorityWorker;
+ this.consumer = consumer;
+
+ PluginDebug.debug("Worker " + this.id + " (priority=" + isPriorityWorker + ") created.");
+ }
+
+ public void setmessage(String message) {
+ this.message = message;
+ }
+
+ public void run() {
+ while (true) {
+
+ if (message != null) {
+
+ PluginDebug.debug("Consumer (priority=" + isPriorityWorker + ") thread " + id + " consuming " + message);
+
+ // ideally, whoever returns things object should mark it
+ // busy first, but just in case..
+ busy();
+
+ try {
+ streamHandler.handleMessage(message);
+ } catch (PluginException pe) {
+ /*
+ catch the exception and DO NOTHING. The plugin should take over after
+ this error and let the user know. We don't quit because otherwise the
+ exception will spread to the rest of the applets which is a no-no
+ */
+ }
+
+ this.message = null;
+
+ PluginDebug.debug("Consumption (priority=" + isPriorityWorker + ") completed by consumer thread " + id);
+
+ // mark ourselves free again
+ free();
+
+ } else {
+
+ // 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
+ }
+ }
+ }
+ }
+
+ public int getWorkerId() {
+ return id;
+ }
+
+ public void busy() {
+ synchronized (this) {
+ this.free = false;
+ }
+ }
+
+ public void free() {
+ synchronized (this) {
+ this.free = true;
+
+ // Signal the consumer that we are done in case it was waiting
+ consumer.notifyWorkerIsFree(this);
+ }
+ }
+
+ public boolean isPriority() {
+ return isPriorityWorker;
+ }
+
+ public boolean isFree(boolean prioritized) {
+ synchronized (this) {
+ return free && (prioritized == isPriorityWorker);
}
- }
-
- public void free() {
- synchronized (this) {
- this.free = true;
-
- // Signal the consumer that we are done in case it was waiting
- consumer.notifyWorkerIsFree(this);
- }
- }
-
- public boolean isPriority() {
- return isPriorityWorker;
- }
-
- public boolean isFree(boolean prioritized) {
- synchronized (this) {
- return free && (prioritized == isPriorityWorker);
- }
- }
-
- public String toString() {
- return "Worker #" + this.id + "/IsPriority=" + this.isPriorityWorker + "/IsFree=" + this.free + "/Message=" + message;
- }
+ }
+
+ public String toString() {
+ return "Worker #" + this.id + "/IsPriority=" + this.isPriorityWorker + "/IsFree=" + this.free + "/Message=" + message;
+ }
}