Offload startCoroutineUnintercepted to separate thread to avoid races on completed deferred in StackTraceRecoveryTest
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
index db5fabc..e7b46cd 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
@@ -10,6 +10,7 @@
import kotlinx.coroutines.selects.*
import org.junit.Test
import java.util.concurrent.*
+import kotlin.concurrent.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -292,10 +293,13 @@
val barrier = CyclicBarrier(2)
var exception: Throwable? = null
- await.startCoroutineUnintercepted(Continuation(EmptyCoroutineContext) {
- exception = it.exceptionOrNull()
- barrier.await()
- })
+
+ thread {
+ await.startCoroutineUnintercepted(Continuation(EmptyCoroutineContext) {
+ exception = it.exceptionOrNull()
+ barrier.await()
+ })
+ }
barrier.await()
val e = exception