Patent ID: 8122449

Claim:
A computer-implemented method for workload balancing, comprising: receiving a value for a low water mark, wherein the low water mark represents a minimum number of threads in a thread pool; for each of one or more channels that are serviced by the threads in the thread pool, receiving a value, wherein the value represents a maximum number of threads that are allowed to be waiting for messages to arrive on the channel; receiving a message on a channel of the one or more channels; selecting a thread in the thread pool to process the message, wherein the thread is assigned to the channel to process the message for the channel; in response to determining that the message has been processed and a response has been sent on the channel by the thread, determining whether a total number of threads in the thread pool is greater than the value of the low water mark plus one and whether the channel has more than the value of the maximum number of threads; in response to determining that the total number of threads in the thread pool is greater than the value of the low water mark plus one and that the channel has more than the value of the maximum number of threads terminate the thread from the thread pool; and in response to determining at least one of the total number of threads in the thread pool is less than or equal to the value of the low water mark plus one and the channel has less than or equal to the value of the maximum number of threads, retain the thread in the thread pool.