+ 1

Why async output is not as expected

Hi Please find below code: https://code.sololearn.com/cA15A23A6A3a I thought that "Completed..." should be printed before result as it was computed in async task. Why output is not in proper order?

10th Mar 2021, 11:27 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 odpowiedzi
+ 3
Async != parallelism Parallelism is done via threads, and asynchrone is done via futures.
10th Mar 2021, 11:37 AM
Théophile
Théophile - avatar
0
I thought argument launch::async is creating thread only...
10th Mar 2021, 12:16 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Please refer below sample code. We can observe that thread ID is different for async. https://code.sololearn.com/c6a166a6a57A
11th Mar 2021, 9:57 AM
Ketan Lalcheta
Ketan Lalcheta - avatar