Last active
January 11, 2021 12:08
-
-
Save SergejIsbrecht/325000c247ed35a810430a02f2b568f0 to your computer and use it in GitHub Desktop.
timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun fuck1() { | |
val dmb = io.reactivex.schedulers.Schedulers.single() | |
val watchDog = io.reactivex.schedulers.Schedulers.from(Executors.newSingleThreadExecutor()) | |
watchDog.scheduleDirect { | |
println("watchDog scheduleDirect " + Thread.currentThread().name) | |
} | |
dmb.scheduleDirect { | |
// println("block this thread " + Thread.currentThread().name) | |
// Thread.sleep(10_000) | |
} | |
val watchDogA = AtomicBoolean(false) | |
watchDog.scheduleDirect({ | |
watchDogA.compareAndExchange(false, true) | |
println("watchDog scheduleDirect delayed" + Thread.currentThread().name) | |
}, 3, TimeUnit.SECONDS) | |
Thread.sleep(5_000) | |
assertThat(watchDogA.get()).isTrue() | |
} | |
@Test | |
fun fuck2() { | |
val dmb = io.reactivex.schedulers.Schedulers.single() | |
val watchDog = io.reactivex.schedulers.Schedulers.from(Executors.newSingleThreadExecutor()) | |
watchDog.scheduleDirect { | |
println("watchDog scheduleDirect " + Thread.currentThread().name) | |
} | |
dmb.scheduleDirect { | |
println("block this thread " + Thread.currentThread().name) | |
Thread.sleep(10_000) | |
} | |
val watchDogA = AtomicBoolean(false) | |
watchDog.scheduleDirect({ | |
watchDogA.compareAndExchange(false, true) | |
println("watchDog scheduleDirect delayed" + Thread.currentThread().name) | |
}, 3, TimeUnit.SECONDS) | |
Thread.sleep(5_000) | |
assertThat(watchDogA.get()).isTrue() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment