/[classpath]/classpath/java/lang/InheritableThreadLocal.java
ViewVC logotype

Diff of /classpath/java/lang/InheritableThreadLocal.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by ericb, Sun Mar 24 23:42:38 2002 UTC revision 1.7 by mark, Sat Aug 9 18:47:04 2003 UTC
# Line 1  Line 1 
1  /* InheritableThreadLocal -- a ThreadLocal which inherits values across threads  /* InheritableThreadLocal -- a ThreadLocal which inherits values across threads
2     Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.     Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 37  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package java.lang;  package java.lang;
39    
40    import java.util.ArrayList;
41    import java.util.Collections;
42  import java.util.Iterator;  import java.util.Iterator;
43  import java.util.List;  import java.util.List;
44  import java.util.ArrayList;  import java.util.Map;
45  import java.util.WeakHashMap;  import java.util.WeakHashMap;
46    
47  /**  /**
# Line 67  public class InheritableThreadLocal exte Line 69  public class InheritableThreadLocal exte
69     * List can be collected, too. Maps to a list in case the user overrides     * List can be collected, too. Maps to a list in case the user overrides
70     * equals.     * equals.
71     */     */
72    private static final WeakHashMap threadMap = new WeakHashMap();    private static final Map threadMap
73              = Collections.synchronizedMap(new WeakHashMap());
74    
75    /**    /**
76     * Creates a new InheritableThreadLocal that has no values associated     * Creates a new InheritableThreadLocal that has no values associated
# Line 77  public class InheritableThreadLocal exte Line 80  public class InheritableThreadLocal exte
80    {    {
81      Thread currentThread = Thread.currentThread();      Thread currentThread = Thread.currentThread();
82      // Note that we don't have to synchronize, as only this thread will      // Note that we don't have to synchronize, as only this thread will
83      // ever modify the returned heritage.      // ever modify the returned heritage and threadMap is a synchronizedMap.
84      List heritage = (List) threadMap.get(currentThread);      List heritage = (List) threadMap.get(currentThread);
85      if (heritage == null)      if (heritage == null)
86        {        {
# Line 114  public class InheritableThreadLocal exte Line 117  public class InheritableThreadLocal exte
117      // The currentThread is the parent of the new thread.      // The currentThread is the parent of the new thread.
118      Thread parentThread = Thread.currentThread();      Thread parentThread = Thread.currentThread();
119      // Note that we don't have to synchronize, as only this thread will      // Note that we don't have to synchronize, as only this thread will
120      // ever modify the returned heritage.      // ever modify the returned heritage and threadMap is a synchronizedMap.
121      ArrayList heritage = (ArrayList) threadMap.get(parentThread);      ArrayList heritage = (ArrayList) threadMap.get(parentThread);
122      if (heritage != null)      if (heritage != null)
123        {        {

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26