3 ms·
If I’m using threads for each of my tasks, then why do I need async at all? I find mixing async and threads is messy, because it’s hard to take a lock in async
by CJefferson 1y ago
If I’m using threads for each of my tasks, then why do I need async at all? I find mixing async and threads is messy, because it’s hard to take a lock in async code, as that blocks other async code from running. I’m sure this can be done well, but I failed when I tried.
- nemothekid 1y agoYou can map N-async tasks onto M-threads. This is essentially what Rust does, and if you squint this is how Go works as well. A go routine is not that different from an async task, except the runtime inserts all the await points for you.
- seabrookmx 1y agoIt depends what framework/language you're using. It's messy in something like Python, but mostly transparent in C#. In C# you effectively are using async/await to provide M-N threading ala. GoLang, it's just different syntax. OP references the C# method Task.WhenAll so they might be assuming other languages are equally capable.