View Javadoc

1   package org.slf4j.impl;
2   
3   import java.util.HashMap;
4   
5   /**
6    * This class extends InheritableThreadLocal so that children threads get a copy
7    * of the parent's hashmap.
8    * 
9    * @author Ceki Gülcü
10   */
11  public class CopyOnInheritThreadLocal extends
12      InheritableThreadLocal<HashMap<String, String>> {
13  
14    /**
15     * Child threads should get a copy of the parent's hashmap.
16     */
17    @Override
18    protected HashMap<String, String> childValue(
19        HashMap<String, String> parentValue) {
20      if (parentValue == null) {
21        return null;
22      } else {
23        HashMap<String, String> hm = new HashMap<String, String>(parentValue);
24        return hm;
25      }
26    }
27  
28  }