InheritableThreadLocal.java revision 0
0N/A * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * This class extends <tt>ThreadLocal</tt> to provide inheritance of values 0N/A * from parent thread to child thread: when a child thread is created, the 0N/A * child receives initial values for all inheritable thread-local variables 0N/A * for which the parent has values. Normally the child's values will be 0N/A * identical to the parent's; however, the child's value can be made an 0N/A * arbitrary function of the parent's by overriding the <tt>childValue</tt> 0N/A * method in this class. 0N/A * <p>Inheritable thread-local variables are used in preference to 0N/A * ordinary thread-local variables when the per-thread-attribute being 0N/A * maintained in the variable (e.g., User ID, Transaction ID) must be 0N/A * automatically transmitted to any child threads that are created. 0N/A * @author Josh Bloch and Doug Lea 0N/A * Computes the child's initial value for this inheritable thread-local 0N/A * variable as a function of the parent's value at the time the child 0N/A * thread is created. This method is called from within the parent 0N/A * thread before the child is started. 0N/A * This method merely returns its input argument, and should be overridden 0N/A * if a different behavior is desired. 0N/A * @param parentValue the parent thread's value 0N/A * @return the child thread's initial value 0N/A * Get the map associated with a ThreadLocal. 0N/A * @param t the current thread 0N/A * Create the map associated with a ThreadLocal. 0N/A * @param t the current thread 0N/A * @param firstValue value for the initial entry of the table. 0N/A * @param map the map to store.