A method, system, and program for monitoring thread usage to dynamically
control a thread pool are provided. An application running on the server
system invokes a listener thread on a listener socket for receiving
client requests at the server system and passing the client requests to
one of multiple threads waiting in a thread pool. Additionally, the
application sends an ioctl call in blocking mode on the listener thread.
A TCP layer within the server system detects the listener thread in
blocking mode and monitors a thread count of at least one of a number of
incoming requests waiting to be processed and a number of said plurality
of threads remaining idle in the thread pool over a sample period. Once
the TCP layer detects a thread usage event, the ioctl call is returned
indicating the thread usage event with the thread count, such that a
number of threads in the thread pool may be dynamically adjusted to
handle the thread count.