Fixed run lockings
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
f7876dc964
commit
159805701c
@ -320,12 +320,19 @@ public final class ReadingRunnable implements Runnable {
|
|||||||
* @see java.lang.Runnable#run() */
|
* @see java.lang.Runnable#run() */
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (running) {
|
boolean cont = true;
|
||||||
|
while (cont) {
|
||||||
|
synchronized (lock) {
|
||||||
|
cont = running;
|
||||||
|
if (!running) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
// Buffer end
|
// Buffer end
|
||||||
running = false;
|
setRunning(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOGGER.finer("Read: " + line); //$NON-NLS-1$
|
LOGGER.finer("Read: " + line); //$NON-NLS-1$
|
||||||
@ -335,17 +342,21 @@ public final class ReadingRunnable implements Runnable {
|
|||||||
lock.notifyAll();
|
lock.notifyAll();
|
||||||
}
|
}
|
||||||
} catch (final InterruptedIOException e) {
|
} catch (final InterruptedIOException e) {
|
||||||
|
synchronized (lock) {
|
||||||
if (running) {
|
if (running) {
|
||||||
LOGGER.info("Reading interrupted"); //$NON-NLS-1$
|
LOGGER.info("Reading interrupted"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
}
|
||||||
LOGGER.log(Level.FINER, "Read interruption was caused by an exception", //$NON-NLS-1$
|
LOGGER.log(Level.FINER, "Read interruption was caused by an exception", //$NON-NLS-1$
|
||||||
e);
|
e);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
LOGGER.log(Level.FINE, "The stream reading threw an exception", //$NON-NLS-1$
|
LOGGER.log(Level.FINE, "The stream reading threw an exception", //$NON-NLS-1$
|
||||||
e);
|
e);
|
||||||
|
synchronized (lock) {
|
||||||
if (running) {
|
if (running) {
|
||||||
LOGGER.severe("Unable to read from stream"); //$NON-NLS-1$
|
LOGGER.severe("Unable to read from stream"); //$NON-NLS-1$
|
||||||
running = false;
|
setRunning(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,11 @@ public final class WritingRunnable implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
|
synchronized (lock) {
|
||||||
if (running) {
|
if (running) {
|
||||||
LOGGER.log(Level.SEVERE, "Thread interruption exception.", e); //$NON-NLS-1$
|
LOGGER.log(Level.SEVERE, "Thread interruption exception.", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user