Skip to content

Kotlin offers a nice feature known as coroutine - a high-level framework, to perform anything asynchronously, coordinate tasks behind the scenes. It will make the developer's life easier. Code readability, conciseness, and easier thread management.

Notifications You must be signed in to change notification settings

DevOpsThinh/Kotlin-Coroutines

Repository files navigation

Thanks for your reading, please give me a STAR!

"It is far easier to design a class to be thread-safe than to retrofit it for thread safety later."

(Brian Goetz - Java concurrency: Publisher: Addison-Wesley Professional, Year: 2006; 2013)


Coroutine

A coroutine is Kotlin's way of tackling asynchronous operations, multi-threaded programming
or manging concurrency.
According to Coroutine Team, Java threads have below problems:

  • Context switching for thread can be a costly operation;
  • Various the various OS does restrict the number of threads created by per app. They can
    be infinite;
  • There are still a few platforms that do not support threads (JavaScript);
  • It's always difficult to debug threads;
  • Dealing with race conditions can be a nightmare.

=> Coroutine has answered all the above problems & it also runs in parallel.

Used Software Info:

Kotlin v1.6, IntelliJ IDEA Education Edition, JDK 1.8

References

About

Kotlin offers a nice feature known as coroutine - a high-level framework, to perform anything asynchronously, coordinate tasks behind the scenes. It will make the developer's life easier. Code readability, conciseness, and easier thread management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages