https://kotlinlang.org logo
e

elizarov

04/11/2017, 5:32 PM
The other, less obvious benefit, it that it makes your apps more resilient to failure in external services. E.g. if you use
runAsync1
and due to some 3rd party service failure your tasks become slow, then your app might quickly run out of memory (each thread takes a lot of it) even if your request rate is not very high. With
runAsync2
(given that calls to 3rd party service are suspended while waiting for an answer) your suspended tasks are cheap. You easily can have millions of them suspended, while still continuing to serve other requests