Why should Java ThreadLocal variables be static

Posted by kellyfj on Stack Overflow See other posts from Stack Overflow or by kellyfj
Published on 2010-05-06T19:54:23Z Indexed on 2010/05/06 19:58 UTC
Read the original article Hit count: 178

Filed under:
|

I was reading that JavaDoc for Threadlocal here

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadLocal.html

and it says "ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID). "

But my question is why did they choose to make it static (typically) - it makes it a bit confusing to have "per thread" state but its static?

© Stack Overflow or respective owner

Related posts about java

Related posts about threads