2 ms·
Sure, you can rewrite a program using lightweight threads to an async/await model and vice versa. I find the difference is in how easy it is to reason about con
by initplus 5y ago
Sure, you can rewrite a program using lightweight threads to an async/await model and vice versa. I find the difference is in how easy it is to reason about concurrency in the program.
With threads I find I can more easily mentally organise which code in my application is executing in parallel.
In async/await land, you end up with 2 classes of functions async & non async functions, it's up to the callee to determine wether it is a blocking call or not. With threads you just block by default, and let the caller determine whether it's appropriate to block or execute the function on another thread. See https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-... for someone mere eloquent than myself.