ThreadLocal.InitialValue Method

Definition

Returns the current thread's "initial value" for this thread-local variable.

[Android.Runtime.Register("initialValue", "()Ljava/lang/Object;", "GetInitialValueHandler")]
protected virtual Java.Lang.Object? InitialValue ();
[<Android.Runtime.Register("initialValue", "()Ljava/lang/Object;", "GetInitialValueHandler")>]
abstract member InitialValue : unit -> Java.Lang.Object
override this.InitialValue : unit -> Java.Lang.Object

Returns

the initial value for this thread-local

Attributes

Remarks

Returns the current thread's "initial value" for this thread-local variable. This method will be invoked the first time a thread accesses the variable with the #get method, unless the thread previously invoked the #set method, in which case the initialValue method will not be invoked for the thread. Normally, this method is invoked at most once per thread, but it may be invoked again in case of subsequent invocations of #remove followed by #get.

This implementation simply returns null; if the programmer desires thread-local variables to have an initial value other than null, ThreadLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used.

Java documentation for java.lang.ThreadLocal.initialValue().

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