commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #3229] ThreadLocal and InheritableThreadLocal need to synchronize a


From: nobody
Subject: [bug #3229] ThreadLocal and InheritableThreadLocal need to synchronize access to the map
Date: Fri, 11 Jul 2003 13:51:16 -0400
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20030306 Camino/0.7

=================== BUG #3229: LATEST MODIFICATIONS ==================
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3229&group_id=85

Changes by: Anonymous user        Date: Fri 07/11/2003 at 13:51

------------------ Additional Follow-up Comments ----------------------------
At my company we have an ExecutionContext which holds data for executions, 
which can be a transaction or a thread in the case of not having a transaction. 
 In out case we store a map in the ExecutionContext object.  Since our code 
guarantees that only one thread can be associated with the context at a time, 
we do not need to synchronize on the map in the.  You should put the map for 
this ThreadLocal object in the Thread object, because only that thread can be 
associated with the thread.



=================== BUG #3229: FULL BUG SNAPSHOT ===================


Submitted by: davidholmes             Project: classpath                    
Submitted on: Wed 04/16/2003 at 02:48
Severity:  5 - Major                  Resolution:  None                     
Assigned to:  None                    Status:  Open                         
Platform Version:  None               

Summary:  ThreadLocal and InheritableThreadLocal need to synchronize access to 
the map

Original Submission:  Inside Threadlocal and InheritableThreadLocal are 
comments like:

// Note that we don't have to synchronize, as only this 
//thread will ever modify the returned value.

While it is true that only one thread will ever deal with the return value from 
the map, the map itself is written and read concurrently by multiple threads. 
Hence access to the map *must* be synchronized.

Note that there is a much better way to implement thread locals that avoids the 
need for any synchronization. Unfortunately I can't say anymore as the 
technique is used by the JDK. Think carefully about what it means to be 
thread-local. You might also want to checkout how other systems implement 
thread-local storage.

Follow-up Comments
*******************

-------------------------------------------------------
Date: Fri 07/11/2003 at 13:51       By: None
At my company we have an ExecutionContext which holds data for executions, 
which can be a transaction or a thread in the case of not having a transaction. 
 In out case we store a map in the ExecutionContext object.  Since our code 
guarantees that only one thread can be associated with the context at a time, 
we do not need to synchronize on the map in the.  You should put the map for 
this ThreadLocal object in the Thread object, because only that thread can be 
associated with the thread.


CC list is empty


No files currently attached


For detailed info, follow this link:
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3229&group_id=85

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]