标签:
public class Test
{
private int id;
private String name;
private static long count;
private final static ThreadLocal tl=new ThreadLocal();
public Test()
{
super();
count++;
tl.set(count);
}
public long getCount()
{
return (Long)tl.get();
}
public static void main(String[] args)
{
for (int i = 0; i < 5; i++)
{
Test t=new Test();
System.out.println(t.getCount());
}
}
}
标签:
原文地址:http://www.cnblogs.com/274761783cyf/p/4888204.html