1. https://www.kotlincn.net/docs/reference/coroutines/cancellation-and-timeouts.html
runBlocking 也是非常有用的,,,用在很多需要 立即运行,,不能挂起的场合
2.
阻塞线程 |
表达式内部 是否有返回值 |
并发执行 | |
runBlocking |
true | true | false(串行) |
withContext | false | true | false |
launch |
false | false | false |
asyc | false | true | true |
3.安卓的StrictMode模式似乎不识别 launch(Dispatchers.IO) 的线程切换
StrictMode: StrictMode policy violation: android.os.strictmode.NetworkViolation
需要使用 launch(newSingleThreadContext("xxxxThread"))