hellosagar / android-interview-questions

I'm contributing to help others!
MIT License
48 stars 15 forks source link

If 2 task is running then 1 task crash how to avoid other task to crash #27

Open hellosagar opened 2 years ago

thelumiereguy commented 2 years ago

Task in question is a Coroutine

annamorgiel commented 1 year ago

Assuming both tasks are running inside of a coroutine, we can pass a supervisor job rather than a default job so that when a child fails, the other children are not impacted

https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-supervisor-job.html