4 ms·
If your code is simple with thread pools, it will be just as simple with async/await. The biggest problem with thread pools is that you have a limited number o
by lacker 7y ago
If your code is simple with thread pools, it will be just as simple with async/await.
The biggest problem with thread pools is that you have a limited number of threads. Either because you set an explicit size limit, or you run out of memory. It's really annoying to debug deadlocks that happen because your thread pool is out of threads. So typically applications that use thread pools just don't use parallelism as much as they would if they could use async/await.
There isn't really any advantage of thread pools. Programming in Go, for example, it's very easy to write async calls and quite awkward to explicitly manage threads. But in practice, there are never really any reasons you miss having thread pools.
- gdxhyrd 7y agoIf you are deadlocking, you have a bug. If you hit OOM, you most likely have leaks or went wild with threads or allocations. Both of those conditions are orthogonal to async/thread pools, so what do you mean?
- lacker 7y agoI mean, if your thread pool has 10 threads available, and your code attempts to run an 11th thread, you can run into a deadlock. Whereas that same code written with async/await can run fine. You can call that "going wild with threads" but in an async/await model it is often just fine to use that many async calls.