Open sushmit98 opened 3 years ago
D is more efficient. For C, since f1.join()
comes first in the addition, we'll have to wait for f1 to complete (join()
) before we run f2.compute()
, making it sequential f1 -> f2. Whereas for D, while f1 is running asynchronously on another thread, we run f2.compute()
since it comes first in the addition and it does not need to wait for f1 to complete. In this case, f2 and f1 can run in parallel and we combine both when both are complete.
Alright I understand! Thanks Gabriel!
Hi everoyone, I wanted to ask, for the following question, is C a more efficient way to do it or D? What is the difference between returning f1.join() + f2.compute() vs f2.compute() + f1.join()? Why should the order of addition matter, since both of them will have to wait for each other either ways? Would be glad if someone could shed some light on this for me. Thank you!
Topic:
Parallel Programming, Asynchronous Programming