Skip to content

What is concurrency

Devrath edited this page Jan 10, 2024 · 2 revisions

0_pTKvevWUfgS9CDkK

Understanding about concurrency

  • When we are trying to execute several tasks on a single thread, it leads to a buggy implementation since many tasks try to run simultaneously.
  • With concurrency we make sure multiple tasks run concurrently simultaneously.

Do multiple tasks run parallelly

  • Well kind of
    • Meaning say if there are 4 cores in the CPU, Each core can run a single task.
    • Also if the 1 core is there and has a single thread and multiple tasks are running on it, Still the co-routines are executed in such a way that it appears the tasks are executed concurrently because the co-routines do not block the main thread.

Concurrent-Tasks

  • Concurrent tasks can be completely independent.
  • There can be a relationship between them also in a particular order.

We use co-routines to introduce concurrency to kotlin applications

Clone this wiki locally