https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

ahulyk

03/11/2019, 1:21 PM
Hi Guys! Is there any difference in following shipnets:
Copy code
launch {
        val first = async(IO) {
            transactionDataRepository.getFist()
        }
        val second = async(IO) {
            transactionDataRepository.getSecond()
        }
    }
and
Copy code
launch {
            withContext(IO) {
                val first = async {
                    transactionDataRepository.getFist()
                }
                val second = async {
                    transactionDataRepository.getSecond()
                }
            }
        }
???
a

Allan Wang

03/11/2019, 2:36 PM
I believe they are equivalent, along with
Copy code
launch(IO) {
   async {
      ...
   }
   async {
      ...
   }
}
Though someone else may want to confirm
5 Views