今天发现一个新玩意
来源:13-10 本章小结

慕前端9039556
2022-04-15
/**
* Executes a block using a given coroutine context.
*/
internal actual inline fun <T> withCoroutineContext(context: CoroutineContext, countOrElement: Any?, block: () -> T): T {
val oldValue = updateThreadContext(context, countOrElement)
try {
return block()
} finally {
restoreThreadContext(context, oldValue)
}
}
ThreadContext是个什么概念呢?课程中也没有类似的内容。老师知道么?讲讲呗哈哈哈
写回答
1回答
-
bennyhuo
2022-04-16
自己分析一下吧,我之前没注意到有这个,难道是新版本的?
022022-05-07
相似问题