ThreadPoolExecutor.setKeepAliveTime

Sets the thread keep-alive time, which is the amount of time that threads may remain idle before being terminated. Threads that wait this amount of time without processing a task will be terminated if there are more than the core number of threads currently in the pool, or if this pool {@linkplain #allowsCoreThreadTimeOut() allows core thread timeout}. This overrides any value set in the constructor.

@param time the time to wait. A time value of zero will cause excess threads to terminate immediately after executing tasks. @param unit the time unit of the {@code time} argument @throws IllegalArgumentException if {@code time} less than zero or if {@code time} is zero and {@code allowsCoreThreadTimeOut} @see #getKeepAliveTime(TimeUnit)

class ThreadPoolExecutor
void
setKeepAliveTime
(
Duration time
)

Meta