android-interview-questions icon indicating copy to clipboard operation
android-interview-questions copied to clipboard

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

Open hellosagar opened this issue 3 years ago • 2 comments

hellosagar avatar Jun 02 '22 12:06 hellosagar

Task in question is a Coroutine

thelumiereguy avatar Jun 21 '22 10:06 thelumiereguy

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

annamorgiel avatar Mar 12 '23 17:03 annamorgiel