ThreadPoolExecutor.SetKeepAliveTime(Int64, TimeUnit) Method

Definition

Sets the thread keep-alive time, which is the amount of time that threads may remain idle before being terminated.

[Android.Runtime.Register("setKeepAliveTime", "(JLjava/util/concurrent/TimeUnit;)V", "GetSetKeepAliveTime_JLjava_util_concurrent_TimeUnit_Handler")]
public virtual void SetKeepAliveTime (long time, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("setKeepAliveTime", "(JLjava/util/concurrent/TimeUnit;)V", "GetSetKeepAliveTime_JLjava_util_concurrent_TimeUnit_Handler")>]
abstract member SetKeepAliveTime : int64 * Java.Util.Concurrent.TimeUnit -> unit
override this.SetKeepAliveTime : int64 * Java.Util.Concurrent.TimeUnit -> unit

Parameters

time
Int64

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

unit
TimeUnit

the time unit of the time argument

Attributes

Exceptions

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

Remarks

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() allows core thread timeout. This overrides any value set in the constructor.

Java documentation for java.util.concurrent.ThreadPoolExecutor.setKeepAliveTime(long, java.util.concurrent.TimeUnit).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also