package com.atguigu.docker.锁;
import lombok.SneakyThrows;
public class t2 extends Thread{
static int aa=1;
@Override
public void run() {
n();
}
public synchronized void n(){
while (aa<100){
aa+=1;
System.out.println(Thread.currentThread().getName()+"aa="+aa);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}}
}
}
t2 s2 = new t2();
t2 s3 = new t2();
t2 s4 = new t2();
s2.start();
s3.start();
s4.start();
这里有三个实例, synchronized 锁的this是哪个? 这里的同步成功了吗