What are coroutines,How are they make asynchronous operation easy in Kotlin ?

Updated 16 April 2018


Coroutine are light-weight threads. A light weight thread means it doesn’t map on native thread, so it doesn’t require context switching on processor, so they are faster. Coroutines  is a new way of writing asynchronous, non-blocking code in kotlin.

How to implement corountine ?

These are the functions to start the coroutine:

1. launch{}

2. async{}

Launch vs Async in Kotlin Coroutines

The difference is that the launch{} does not return anything and the async{} returns an instance of Deferred<T>, which has an await function that returns the result of the coroutine like we have future in Java. and we do future.get() in Java to  the get the result.

Let see the use of async?




. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home