Why comment this line15 ,also get the same output?
# coroutines
t
Why comment this line15 ,also get the same output?
https://kotlinlang.org/docs/cancellation-and-timeouts.html#cancelling-coroutine-execution I follow offical doc,I don't known why already call cancel() method then call join(),Why not join() first then cancel(), What is the point of calling the join() method after cancel()
e
.join()
blocks the current coroutine until the job is completed
.cancel()
asynchronously cancels the job. it may continue running if it is in the middle of blocking code or
withContext(NonCancellable) { }
`.cancel()`+`.join()` will cancel the job and wait for it to end. there is a
.cancelAndJoin()
convenience extension function which is equivalent
.join()
+
.cancel()
will wait for the job to complete, and then cancel nothing. this is not useful
👍 1