In this chapter, we covered how to create threads and coroutines in Kotlin, and the benefits of coroutines.
Kotlin has simplified syntax for creating threads, compared to Java. But they still have the overhead of memory and often performance. Coroutines are able to solve these issues; use coroutines whenever you need to execute some code concurrently.
If you want to communicate between two coroutines, use channels.
Kotlin also offers actors with the actor() function, which also spins a coroutine that has an inbound stream attached to it to process events. And if you need to create a stream of values, you can use the produce() function.
In the next chapter, we'll discuss how we can use these concurrency primitives to create scalable and robust systems that suit our needs.