eygraber
02/24/2025, 6:16 PMnewFixedThreadPoolContext
use Executors.newScheduledThreadPool
(which is bounded by nThreads..Int.MAX_VALUE
) instead of Executors.newFixedThreadPool
(which is bounded by nThreads..nThreads
)?eygraber
02/24/2025, 6:27 PMScheduledThreadPoolExecutor
? Then either specify the maximumPoolSize
or change the name (or at least mention it in the docs)?Dmitry Khalanskiy [JB]
02/25/2025, 8:29 AMnewFixedThreadPoolContext(n)
can contain more than n
threads? A simple experiment doesn't show this: https://pl.kotl.in/QmqJMp0Da Could you describe a specific problematic scenario?eygraber
02/25/2025, 8:32 AMn
threads?Dmitry Khalanskiy [JB]
02/25/2025, 8:33 AMCreates a coroutine execution context with the fixed-size thread-pool
n
is the fixed size.eygraber
02/25/2025, 8:37 AMExecutors.newScheduledThreadPool
and doesn't set an upper boundDmitry Khalanskiy [JB]
02/25/2025, 8:37 AMeygraber
02/25/2025, 8:41 AMn
threads when the executor isn't preventing itDmitry Khalanskiy [JB]
02/25/2025, 8:49 AMeygraber
02/25/2025, 8:57 AMThreadPoolExecutor
getting called with corePoolSize=4
and maximumPoolSize=Int.MAX_VALUE
. The javadoc for those says:
corePoolSize – the number of threads to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set
maximumPoolSize – the maximum number of threads to allow in the poolwhich sounds like it will always keep at least 4 threads, but can grow to
Int.MAX_VALUE
threads.Dmitry Khalanskiy [JB]
02/25/2025, 11:29 AMeygraber
02/25/2025, 2:56 PMUsing a custom queue (DelayedWorkQueue), a variant of unbounded DelayQueue.
Since it used an unbounded queue, it shouldn't create more than
n
threads.