/** * Removes the current thread's value for this thread-local variable. * * @see ThreadLocal#remove() */ public void remove() { set(null); }
/** * Returns the value in the current thread's copy of this thread-local variable. * * @see ThreadLocal#get() */ public final T get() { int id = (int)Thread.currentThread().getId(); T[] threadIDMap = this.threadIDMap; // It's OK if the array is resized after this access, will just use the old array. T value = threadIDMap.length <= id ? null : threadIDMap[id]; if ( value == null ) { value = initialValue(); set(value); } return value; }