native-mt 和普通 kotlin 协程库有什么区别?

Ely*_*lye 14 kotlin kotlin-multiplatform kotlin-coroutines

当我们使用协程时,我们可以使用普通的 kotlin 协程,也可以使用版本native-mt

IE

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
Run Code Online (Sandbox Code Playgroud)

或者

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-native-mt'
Run Code Online (Sandbox Code Playgroud)

他们之间有什么区别吗?我们什么时候应该使用哪个?

Joh*_*lly 14

它基本上提供了在 Kotlin/Native 代码中使用多线程的功能(通常作为 Kotlin 多平台 (KMP) 项目的一部分)。更多信息请参见https://kotlinlang.org/docs/mobile/concurrency-and-coroutines.html#multithreaded-coroutines。这也是许多 KMP 库(例如Ktor)现在使用的版本,并且通常是开发 KMP 应用程序时的要求。