I have a question is there any difference between ...
# coroutines
m
I have a question is there any difference between
Copy code
launch(Dispatchers.Unconfined)
and
Copy code
launch(start = CoroutineStart.UNDISPATCHED)
? afaiu both will excute job immediatley in the same thread right?
e
Yes. However, after the first suspension they will behave differently. The first one will continue to be unconfined (will resume in an arbitrary thread driven by the suspending function that was used), while the second one will resume in the thread that is defined by its dispatcher.
👍 2
m
oh shit, then this makes a different then
Copy code
mainScope.launch(dispatcher = UNCONFINED) {
 ui.update()
 val result = retrofit.fetchResult() //<- retrofit uses non UI thread by default
 ui.updateResult() //<- this would beexecuted on non UI thread and eventually lead to crash
}
👍 1
d
Unconfined was changed to use fair ordering no? In that case it would not be the same as UNDISPATCHED?
Prior to the first suspension