ThreadLocal uses WeakHashMap

You can infer
* when a jvm thread dies, the Thread object is garbage collected.
* WeakHashMap is reliable

There’s no weak concurrent map.

Q: how is ThreadLocal faster in jdk 1.5? Using concurrent hash map? Atomic variables?
A: http://stackoverflow.com/questions/1202444/how-is-javas-threadlocal-implemented-under-the-hood

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s