| Author |
ThreadLocal use to store Key and Value (like hash map)
|
Shankar sanjay
Ranch Hand
Joined: Sep 14, 2009
Posts: 104
|
|
Hi,
I have a requirement in my project to store and get values throughout the transaction (like hashmap, key and value). As far as i know, we can store only one object (like list) in ThreadLocal.
Is there any want to store key and value in ThreadLocal.
please help me.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16692
|
|
Shankar sanjay wrote:
I have a requirement in my project to store and get values throughout the transaction (like hashmap, key and value). As far as i know, we can store only one object (like list) in ThreadLocal.
Is there any want to store key and value in ThreadLocal.
One option.... store a Map object in the ThreadLocal.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Shankar sanjay
Ranch Hand
Joined: Sep 14, 2009
Posts: 104
|
|
|
thanks Henry. Do you have any sample code?
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2331
|
|
|
Google has many sample codes. Try java threadlocal examples.
|
 |
 |
|
|
subject: ThreadLocal use to store Key and Value (like hash map)
|
|
|