-
Notifications
You must be signed in to change notification settings - Fork 22
What is concurrency
Devrath edited this page Jan 10, 2024
·
2 revisions
- 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.
- 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.
- Meaning say if there are
- 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