July 2018
Intermediate to advanced
242 pages
8h 6m
English
The preceding code is going to print the following text to the console:
Running on mainStarting async operation on Thread-0Starting async operation on Thread-1Ending async operation on Thread-1Ending async operation on Thread-0
As you can see, we have successfully started two background threads, which are running concurrently. We are using the thread() utility function from the kotlin.concurrent package, which is responsible for instantiating and starting a new thread that runs a block of code passed to it in the form of a lambda expression.
Read now
Unlock full access