About the Thread.start issue, I think you went too far. Kotlin coroutines are very different from Thread, and I'm not sure they are as much part of the language anyway...
If you want something more similar, it should have been.... "thread" .
You use it this way:
thread{
//do something in the newly created thread.
}
You're right, Kotlin Coroutines are very different from Java Threads. For example, one can write a Coroutine that runs on the same main thread as the regular code (and doesn't use any other threads at all).
My point here was: Coroutines are quite becoming the default to do concurrency operations in Kotlin (especially since Java threads are not available on all platforms), and they fix things that have not been addressed before. Like the aforementioned example of calling a suspend function, but forgetting to handle it correctly.
I think your example is a really good one to show again how Kotlin makes existing Java-APIs easier to handle, and code easier to write, and fewer possible bugs. π
I'll link to your comment in the article! π
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
About the Thread.start issue, I think you went too far. Kotlin coroutines are very different from Thread, and I'm not sure they are as much part of the language anyway...
If you want something more similar, it should have been.... "thread" .
You use it this way:
That's it.
You're right, Kotlin Coroutines are very different from Java Threads. For example, one can write a Coroutine that runs on the same main thread as the regular code (and doesn't use any other threads at all).
My point here was: Coroutines are quite becoming the default to do concurrency operations in Kotlin (especially since Java threads are not available on all platforms), and they fix things that have not been addressed before. Like the aforementioned example of calling a suspend function, but forgetting to handle it correctly.
I think your example is a really good one to show again how Kotlin makes existing Java-APIs easier to handle, and code easier to write, and fewer possible bugs. π
I'll link to your comment in the article! π