Limiting number of tasks running at once

2019-08-11 14:10发布

I have to run about 150 tasks. Right now the app is using only 25 threads per core and I need that to be a higher number. Is it possible to increase that limit ?

1条回答
ゆ 、 Hurt°
2楼-- · 2019-08-11 14:34

The only way to control the actual number of threads that will actually be created is to implement your own TaskScheduler subclass where you can control the creation and scheduling of the threads on which to execute tasks. The default implementation uses thread pool threads along with several heuristics to determine the maximum number of threads to schedule per core.

Honestly, I'd be amazed if you can beat the default implementation. Are you doing any I/O in these tasks? Are you using async I/O?

查看更多
登录 后发表回答