tokuhirom
06/18/2024, 4:33 PM@ExperimentalForeignApi
fun main() {
// Start a new worker
val worker = Worker.start()
// Schedule a task for execution on the worker
worker.execute(TransferMode.SAFE, {}) {
// Print the thread identifier of the current thread
println("Hello from a background worker!")
}
// request termination of the worker
worker.requestTermination(true).result
}
but i got a warning message like this: Main.kt:11:20 Workers API is obsolete and will be replaced with threads eventually
so, where's the documentation about new "threads" API?ephemient
06/18/2024, 4:43 PMkotlinx.coroutines
Adam S
06/18/2024, 5:28 PMWorkers continue being supported and maintained, but they eventually will be replaced with threads API and then deprecated.https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.native.concurrent/-obsolete-workers-api/
tokuhirom
06/18/2024, 11:01 PMloke
06/20/2024, 12:52 PMpthread_create
. It's a POSIX API, so it's not Kotlin specific.