private static ThreadLocal tl = new ThreadLocal(); public static void main(String[] args) { tl.set("nihao");//容器:Map容器--》[key:當前線程對象,value:nihao] Object o = tl.get();//默認的key是當前線程 System.out.println(o);//nihao tl.remove();//默認的key是當前線程 o = tl.get(); System.out.println(o); }