diff --git a/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java b/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java index 20aea73..daf35a1 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java +++ b/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java @@ -51,6 +51,8 @@ import java.util.logging.Logger; * @author Emmanuel Bigeon */ public class ReadingRunnable implements Runnable { + /** The closed pipe message */ + private static final String CLOSED_PIPE = "Closed pipe"; //$NON-NLS-1$ /** Wait timeout */ private static final long TIMEOUT = 1000; /** Class logger */ @@ -65,6 +67,7 @@ public class ReadingRunnable implements Runnable { /** Synchro object */ private final Object lock = new Object(); + /** The waiting status for a message */ private boolean waiting; /** @param reader the input to read from */ @@ -122,7 +125,7 @@ public class ReadingRunnable implements Runnable { public String getMessage() throws IOException { synchronized (lock) { if (!running) { - throw new IOException("Closed pipe"); //$NON-NLS-1$ + throw new IOException(CLOSED_PIPE); } waiting = true; while (messages.isEmpty()) { @@ -133,7 +136,7 @@ public class ReadingRunnable implements Runnable { e); } if (messages.isEmpty() && !running) { - throw new IOException("Closed pipe"); //$NON-NLS-1$ + throw new IOException(CLOSED_PIPE); } } LOGGER.finest("Polled: " + messages.peek()); //$NON-NLS-1$ @@ -161,19 +164,17 @@ public class ReadingRunnable implements Runnable { public boolean hasMessage() throws IOException { synchronized (lock) { if (!running) { - throw new IOException("Closed pipe"); //$NON-NLS-1$ + throw new IOException(CLOSED_PIPE); } return !messages.isEmpty(); } } - /** - * - */ + /** Interrupts the wait on the next message by providing an empty message */ public void interrupt() { synchronized (lock) { if (waiting) { - messages.offer(""); + messages.offer(""); //$NON-NLS-1$ lock.notify(); } }