aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/InheritableThreadLocal.java
diff options
context:
space:
mode:
author(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-22 21:39:00 +0000
committer(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-22 21:39:00 +0000
commit2e9c0dc38e2692b04281844366dbb367ae1294e1 (patch)
treee56f44693864144d87710daeab9743d4e76b6037 /libjava/java/lang/InheritableThreadLocal.java
parent780b7d9b87ddf306aa31c750d5eb9d96a9cb69ea (diff)
This commit was manufactured by cvs2svn to create tagobjc-improvements-candidate-20030922
'objc-improvements-candidate-20030922'. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/tags/objc-improvements-candidate-20030922@71666 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/InheritableThreadLocal.java')
-rw-r--r--libjava/java/lang/InheritableThreadLocal.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/libjava/java/lang/InheritableThreadLocal.java b/libjava/java/lang/InheritableThreadLocal.java
index 31b64f54798..5dfbe9a6230 100644
--- a/libjava/java/lang/InheritableThreadLocal.java
+++ b/libjava/java/lang/InheritableThreadLocal.java
@@ -1,5 +1,5 @@
/* InheritableThreadLocal -- a ThreadLocal which inherits values across threads
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,9 +37,11 @@ exception statement from your version. */
package java.lang;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
+import java.util.Map;
import java.util.WeakHashMap;
/**
@@ -67,7 +69,8 @@ public class InheritableThreadLocal extends ThreadLocal
* List can be collected, too. Maps to a list in case the user overrides
* equals.
*/
- private static final WeakHashMap threadMap = new WeakHashMap();
+ private static final Map threadMap
+ = Collections.synchronizedMap(new WeakHashMap());
/**
* Creates a new InheritableThreadLocal that has no values associated
@@ -77,7 +80,7 @@ public class InheritableThreadLocal extends ThreadLocal
{
Thread currentThread = Thread.currentThread();
// Note that we don't have to synchronize, as only this thread will
- // ever modify the returned heritage.
+ // ever modify the returned heritage and threadMap is a synchronizedMap.
List heritage = (List) threadMap.get(currentThread);
if (heritage == null)
{
@@ -114,7 +117,7 @@ public class InheritableThreadLocal extends ThreadLocal
// The currentThread is the parent of the new thread.
Thread parentThread = Thread.currentThread();
// Note that we don't have to synchronize, as only this thread will
- // ever modify the returned heritage.
+ // ever modify the returned heritage and threadMap is a synchronizedMap.
ArrayList heritage = (ArrayList) threadMap.get(parentThread);
if (heritage != null)
{