setKeepAliveTime

fun setKeepAliveTime(time: Long, unit: TimeUnit)

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 .allowsCoreThreadTimeOut. This overrides any value set in the constructor.

Parameters

time

the time to wait. A time value of zero will cause excess threads to terminate immediately after executing tasks.

unit

the time unit of the time argument

See also

.getKeepAliveTime

Throws

if time less than zero or if time is zero and allowsCoreThreadTimeOut