# InheritableThreadLocal

public class **InheritableThreadLocal** extends [ThreadLocal](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html)\<T\>  
This class extends ThreadLocal to provide inheritance of values
from parent thread to child thread: when a child thread is created, the
child receives initial values for all inheritable thread-local variables
for which the parent has values. Normally the child's values will be
identical to the parent's; however, the child's value can be made an
arbitrary function of the parent's by overriding the childValue
method in this class.

Inheritable thread-local variables are used in preference to
ordinary thread-local variables when the per-thread-attribute being
maintained in the variable (e.g., User ID, Transaction ID) must be
automatically transmitted to any child threads that are created.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html`

### Public Constructor Summary

|---|---|
|   | [InheritableThreadLocal](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/InheritableThreadLocal.html#InheritableThreadLocal())() |

### Protected Method Summary

|---|---|
| T | [childValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/InheritableThreadLocal.html#childValue(T))(T parentValue) Computes the child's initial value for this inheritable thread-local variable as a function of the parent's value at the time the child thread is created. |

### Inherited Method Summary

From class [java.lang.ThreadLocal](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html)

|---|---|
| T | [get](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html#get())() Returns the value in the current thread's copy of this thread-local variable. |
| T | [initialValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html#initialValue())() Returns the current thread's "initial value" for this thread-local variable. |
| void | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html#remove())() Removes the current thread's value for this thread-local variable. |
| void | [set](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html#set(T))(T value) Sets the current thread's copy of this thread-local variable to the specified value. |
| static \<S\> [ThreadLocal](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html)\<S\> | [withInitial](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadLocal.html#withInitial(java.util.function.Supplier<?%20extends%20S>))([Supplier](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Supplier.html)\<? extends S\> supplier) Creates a thread local variable. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**InheritableThreadLocal**
()

<br />

## Protected Methods

#### protected T
**childValue**
(T parentValue)

Computes the child's initial value for this inheritable thread-local
variable as a function of the parent's value at the time the child
thread is created. This method is called from within the parent
thread before the child is started.


This method merely returns its input argument, and should be overridden
if a different behavior is desired.

##### Parameters

| parentValue | the parent thread's value |
|---|---|

##### Returns

- the child thread's initial value