How to cancel the blocking code in the coroutines
问题 I have the following code structure: @Throws(InterruptedException::class) fun method() { // do some blocking operations like Thread.sleep(...) } var job = launch { method() } job.cancelAndJoin() The method is provided by the external library and I can't control its behaviour. It can take a lot of time for execution, so in some cases it should be canceled by timeout. I can use the withTimeout function provided by the kotlin coroutines library, but it can't cancel a code with blockings due to