When we develop an application, we always have to deal with long-running operations such as networks or file input/output. Using a block of code known as a callback to determine when a task is completed is a traditional approach. However, code with callbacks doesn't look natural and it's clearer to read code that is written in a sequential manner. Kotlin brings coroutines to the world of Java virtual machines, which provide an alternative to threads.
In this chapter, we will cover the following topics:
- What are coroutines?
- Coroutines and threads
- Coroutine examples