hippo4j icon indicating copy to clipboard operation
hippo4j copied to clipboard

[Feature] The number of threads in the thread pool decreases in real time

Open magestacks opened this issue 1 year ago • 3 comments

Demand advice

Please answer these questions before submitting them. Thank you.

Is your function request related to the problem?

NO

Describe the function you want

The number of threads in the thread pool decreases in real time.

Suppose the core and maximum number of threads is 3, n tasks have been run, and the current thread of the thread pool is now 3. And now I've adjusted the number of threads to 1, so when I run the task again, after the task has run, I'll start checking the current thread and the maximum maximum thread, and if it's greater than that, I'll interrupt myself.

I want to do this through the current thread pool plug-in.

@Createsequence

magestacks avatar Apr 30 '23 09:04 magestacks

I will try to complete it

Createsequence avatar Apr 30 '23 10:04 Createsequence

I have a brand new idea, this plugin may be directly used to allow users to quickly and actively destroy worker threads, not limited to destroying worker threads that exceed the maximum number of threads (in fact, this is also an active destruction scenario). Simply put, this plugin can satisfy:

When manually/automatically specify a number n according to a certain strategy, if the current number of threads x (which can be the number of worker threads, or just the number of active threads) is greater than n, the plugin will actively and quickly destroy threads by throwing exceptions.

If this idea is feasible, then the subsequent PR will need to be further adjusted.

Createsequence avatar Aug 15 '23 15:08 Createsequence

The destruction of worker threads should be controlled by allowCoreThreadTimeOut API, Hippo4j I think it is more appropriate to enhance the destruction of non-core threads.

magestacks avatar Aug 16 '23 01:08 magestacks