gpt4 book ai didi

java - 减少有许多 hibernate 线程时使用的操作系统线程数

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:17:57 25 4
gpt4 key购买 nike

我有一个有数百个线程的系统。大多数线程在给定时间内处于 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com