Our delivery service sends customers a text with their two hour delivery window on the morning of delivery. The text is sent asynchronously: the service marks a method @async and Spring runs it on an executor we define as a bean, a ThreadPoolTaskExecutor with setMaxPoolSize(50) and a thread name prefix. We had sized that number carefully against our SMS provider's rate limit.
On a Tuesday in October the provider had a slow morning, with each call taking about three seconds instead of a hundred and fifty milliseconds. By ten o'clock the last texts for the morning window were going out at half past eleven, after many drivers had already knocked and left a card. A thread dump showed one thread with our prefix. It had always been one.
ThreadPoolTaskExecutor defaults to a core size of one, a maximum of Integer.MAX_VALUE and a queue capacity of Integer.MAX_VALUE. A Java thread pool only adds threads above the core size when its queue is full and refuses a task.…