In my project, I create a Java runtime that receives working requests from a client. Work (different size) is divided into a set of tasks and then placed in a queue for processing. There are separate queues for processing each type of task, and each queue is associated with ThreadPool. ThreadPools are tuned so that the overall engine performance is optimal.
This design helps us balance requests efficiently, and large requests do not cause system resources to freeze. However, from time to time, the solution becomes ineffective when some of the queues are empty and their respective thread pools are idle.
To do this better, I was thinking of introducing a job / task theft method so that a heavily loaded queue could get help from other ThreadPools. However, this may require the implementation of my own Executor, because Java does not allow multiple queues to be associated with ThreadPool and does not support the concept of theft.
Read about Fork / Join, but that doesn't sound like my needs. Any suggestions or alternative way to create this solution can be very helpful.
Thanks Andy
source share