Effect of ThreadLocals and side-by-side classloading
问题 Assuming class A{ private static final ThreadLocal<String> tl = new ThreadLocal<String>(); } If A is loaded in just one classloader on the vm, the value of t1 is obvious. But what happens to t1 if A is loaded side-by-side in two different classloaders ? Will the value be shared for a given thread ? 回答1: Interesting question. As Tom Hawtin - tackline explained, you are basically creating to instances of ThreadLocal<String>() . Now let's have a look at how ThreadLocal actually stores the values