类与对象课后作业第一题
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()); } } }
相关文章推荐
- 使用Jil序列化JSON提升Asp.net web api 性能
- Leetcode102: Search in Rotated Sorted Array
- jQuery源码分析之width,height,innerWidth,innerHieght,outerWidth,outerHeight函数
- NYoj-Binary String Matching-KMP算法
- 验证2
- python例子-关于时间time模块
- N点主机管理系统的重装步骤(图文)
- Automatic visual detection of Human behavior:A review from 2000 to 2014
- 编码解码及其原理(Base64/Hex/URLEncoding)
- 《需求工程-软件建模与分析》读书笔记2
- [Albert的专栏]★★objective-c面向对象之——类的继承
- 练手的小项目(1)——智能聊天机器人
- PHP学习路径
- 复合运算符
- 线性表---单链表(创建、找中间节点、删除头元素)
- 关于单位申请进京指标
- Apache Mod/Filter Development
- CRLF和LF
- 黑马程序员——高新技术--枚举
- Android事件分发机制总结