Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-02-07 12:25:27 +0000
committerPaul Pazderski2020-02-12 14:53:14 +0000
commit1174c3ba92868a02950e11aa138a63c5b3241fa8 (patch)
treea17cb8fd6c895417c30abdef66ab55d588745762 /org.eclipse.debug.core
parent641acbdd37d0a0c9773b3c8f4a686efd557b3a81 (diff)
downloadeclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.tar.gz
eclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.tar.xz
eclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.zip
Java 8 added a waitFor method with timeout for the Process class. Using this instead of the plain Thread.sleep can reduce waiting time in some situations from 500 ms down to 10 ms. For the case that Process is not a native process and has no optimized waitFor implementation the situation still improves since the terminated check is performed every 100 ms instead every 500 ms. Change-Id: I0fc54981b53615fbae14d46a6c82a9b85d64b035 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
index 8ee0a099d..1bfb08a1e 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
@@ -20,6 +20,7 @@ import java.nio.charset.UnsupportedCharsetException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
@@ -219,7 +220,11 @@ public class RuntimeProcess extends PlatformObject implements IProcess {
} catch (IllegalThreadStateException ie) {
}
try {
- Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH);
+ if (process != null) {
+ process.waitFor(TIME_TO_WAIT_FOR_THREAD_DEATH, TimeUnit.MILLISECONDS);
+ } else {
+ Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH);
+ }
} catch (InterruptedException e) {
}
attempts++;

Back to the top