File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
kotlinx-coroutines-core/jvm/test/scheduling Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 55package kotlinx.coroutines.scheduling
66
77import kotlinx.coroutines.*
8- import org.junit.*
8+ import org.junit.Test
99import java.lang.Runnable
1010import java.util.concurrent.*
1111import kotlin.coroutines.*
12+ import kotlin.test.*
1213
1314class CoroutineSchedulerTest : TestBase () {
1415
@@ -127,6 +128,29 @@ class CoroutineSchedulerTest : TestBase() {
127128 latch.await()
128129 }
129130
131+ @Test
132+ fun testInterruptionCleanup () {
133+ ExperimentalCoroutineDispatcher (1 , 1 ).use {
134+ val executor = it.executor
135+ var latch = CountDownLatch (1 )
136+ executor.execute {
137+ Thread .currentThread().interrupt()
138+ latch.countDown()
139+ }
140+ latch.await()
141+ Thread .sleep(100 ) // I am really sorry
142+ latch = CountDownLatch (1 )
143+ executor.execute {
144+ try {
145+ assertFalse(Thread .currentThread().isInterrupted)
146+ } finally {
147+ latch.countDown()
148+ }
149+ }
150+ latch.await()
151+ }
152+ }
153+
130154 private fun testUniformDistribution (worker : CoroutineScheduler .Worker , bound : Int ) {
131155 val result = IntArray (bound)
132156 val iterations = 10_000_000
You can’t perform that action at this time.
0 commit comments