Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java19
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java28
2 files changed, 30 insertions, 17 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java
index 7ed21a6ea..d0525f642 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java
@@ -131,10 +131,12 @@ public class InputStreamMonitor {
* Starts a thread which writes the stream.
*/
public void startMonitoring() {
- if (fThread == null) {
- fThread = new Thread((Runnable) this::write, DebugCoreMessages.InputStreamMonitor_label);
- fThread.setDaemon(true);
- fThread.start();
+ synchronized (this) {
+ if (fThread == null) {
+ fThread = new Thread((Runnable) this::write, DebugCoreMessages.InputStreamMonitor_label);
+ fThread.setDaemon(true);
+ fThread.start();
+ }
}
}
@@ -143,9 +145,12 @@ public class InputStreamMonitor {
* monitor and the underlying stream.
*/
public void close() {
- if (fThread != null) {
- Thread thread= fThread;
- fThread= null;
+ Thread thread = null;
+ synchronized (this) {
+ thread = fThread;
+ fThread = null;
+ }
+ if (thread != null) {
thread.interrupt();
}
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java
index bdc2cd539..3a6f1a41c 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java
@@ -134,15 +134,21 @@ public class OutputStreamMonitor implements IBinaryStreamMonitor {
* underlying stream by waiting for the thread to terminate.
*/
protected void close() {
- if (fThread != null) {
- Thread thread = fThread;
+ Thread thread = null;
+
+ synchronized (this) {
+ thread = fThread;
fThread = null;
+ }
+
+ if (thread != null) {
try {
thread.join();
} catch (InterruptedException ie) {
}
- fListeners = new ListenerList<>();
- fBinaryListeners = new ListenerList<>();
+
+ fListeners.clear();
+ fBinaryListeners.clear();
}
}
@@ -304,12 +310,14 @@ public class OutputStreamMonitor implements IBinaryStreamMonitor {
* Starts a thread which reads from the stream
*/
protected void startMonitoring() {
- if (fThread == null) {
- fDone.set(false);
- fThread = new Thread((Runnable) this::read, DebugCoreMessages.OutputStreamMonitor_label);
- fThread.setDaemon(true);
- fThread.setPriority(Thread.MIN_PRIORITY);
- fThread.start();
+ synchronized (this) {
+ if (fThread == null) {
+ fDone.set(false);
+ fThread = new Thread((Runnable) this::read, DebugCoreMessages.OutputStreamMonitor_label);
+ fThread.setDaemon(true);
+ fThread.setPriority(Thread.MIN_PRIORITY);
+ fThread.start();
+ }
}
}

Back to the top