I have basically CPU intensive work that runs in a thread pool. However, the operation has a certain number of external events awaiting the enemies that do not occur evenly in time. Since in Java, as far as I know, there is no thread pool implementation that automatically determines the number of threads based on the observed throughput of the task (as in Microsoft CLR 4), is there at least one way to manually tell the thread pool to increase its size when the blocking operation begins and decreases when it ends?
For example, with 8 cores, the pool size is 8. If the operation is associated with a 100% processor, just use this fixed pool. If there is some kind of blocking operation, you should do this:
pool.increase();
waitForSpecialKeyPress();
pool.decrease();
Here's how to do it in Microsoft's Async C ++ library: Use Unsubscribe Offset Delay
Primk source
share