- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个有数百个线程的系统。大多数线程在给定时间内处于 hibernate 或等待状态,但它们可以随时唤醒。我想减少专用于我的系统的操作系统线程数。你知道一个简单的方法吗?例如,是否有一个线程池包,每当线程进入休眠模式时,它都会存储状态并杀死线程。每当它醒来时,它都会以旧线程的状态启动新线程。
谢谢
最佳答案
你在找类似 ThreadPoolExecutor 的东西吗? ?
An ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods.
Thread pools address two different problems: they usually provide improved performance when executing large numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and managing the resources, including threads, consumed when executing a collection of tasks. Each ThreadPoolExecutor also maintains some basic statistics, such as the number of completed tasks.
关于java - 减少有许多 hibernate 线程时使用的操作系统线程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6360438/
我是一名优秀的程序员,十分优秀!