您的位置:首页 > 其它

类与对象课后作业第一题

2015-10-17 20:54 471 查看
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());
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: