diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java index a3f090dc5b40..e742fd4429b9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java @@ -688,11 +688,11 @@ private static class DetachAllExternallyStartedThreadsExceptCurrentOperation ext @Override protected void operate() { - IsolateThread currentThread = CurrentIsolate.getCurrentThread(); + IsolateThread operationThread = CurrentIsolate.getCurrentThread(); IsolateThread thread = firstThread(); while (thread.isNonNull()) { IsolateThread next = nextThread(thread); - if (thread.notEqual(currentThread) && !wasStartedByCurrentIsolate(thread)) { + if (thread.notEqual(queuingThread) && thread.notEqual(operationThread) && !wasStartedByCurrentIsolate(thread)) { /* * The code below is similar to VMThreads.detachCurrentThread() except that it * doesn't call VMThreads.threadExit(). We assume that this is tolerable