@Override
public void run() {
long data=System.currentTimeMillis();
System.out.println(Thread.currentThread().getName()+"has put data"+data);
new First().showData();
new Second().showData();
}}).start();
}
}
static class First{
public void showData(){
System.out.println(myThreadLoacl.isEmpty());
long data=myThreadLoacl.get(Thread.currentThread());//这里会发生空指针问题,但是上一行却打印的是true,怎么回事
System.out.println("first"+Thread.currentThread().getName()+" "+data);
}
}
static class Second{
public void showData(){
long data=myThreadLoacl.get(Thread.currentThread());
System.out.println("second"+Thread.currentThread().getName()+" "+data);
}
}