4 ms·
Threading is not an alternative to "async" and can't replace it. The alternative to "async" is non-blocking IO and an event loop written by hand, possibly with
by chlorion 4y ago
Threading is not an alternative to "async" and can't replace it.
The alternative to "async" is non-blocking IO and an event loop written by hand, possibly with some threading thrown into the mix for certain tasks. This is exactly what the async runtime is doing behind the scenes, and what languages without first class async support have to do to support this form of concurrency.
Doing an event loop manually is probably going to end up being more difficult and less safe than using the language level async abstractions.
Sometimes just spawning threads is the best solution, but it's fairly wasteful to spawn threads for something like IO, especially if there are many operations in flight (1000+).