限制数量的任务同时运行 [英] Limiting number of tasks running at once

查看:91
本文介绍了限制数量的任务同时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行约150任务。现在的应用程序使用每个核心只有25个线程,我需要的是一个较大的数字。是否有可能增加该限制?

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 ?

推荐答案

要控制将实际创建的线程的实际数量的唯一途径是实现自己的 的TaskScheduler 子类,你可以控制的建立和计划在其上执行任务的线程。默认实现使用线程池中的线程以及若干启发确定的最大线程数每个核心调度。

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.

说实话,我很惊讶,如果你能击败默认的实现。你在做任何I / O完成这些任务?您是否使用异步I / O?

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?

这篇关于限制数量的任务同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆