下面的锁是不一样的。static,是相当于锁类;二非static是锁类的一个实例,即this.
- public static synchronized void abc(int threadNo) {
- 19 for (int i = 1; i < 10000; i++) {
- 20
- 21 System.out.println("No." + threadNo + ":" + i);
- 22 }
- 23 }
- public synchronized void abc(int threadNo) {
- 19 for (int i = 1; i < 10000; i++) {
- 20
- 21 System.out.println("No." + threadNo + ":" + i);
- 22 }
- 23 }
http://blog.csdn.net/yangzhijun_cau/article/details/6432216