一、Synchronized
1、synchronized锁的分类:
1.1、方法级的同步锁
非静态同步方法锁的是当前对象
public class MyLock {
public static void main(String[] args) throws InterruptedException {
Phone phone = new Phone();
new Thread(()->{
phone.sendEmail();
},"t1").start();
Thread.sleep(100L);
new Thread(()->{
phone.sendSMS();
},"t2").start();
/*for (int i = 0; i < 10; i++) {
new Thread(()->{
phone.sendSMS();
},Thread.currentThread().getName()+i).start();
}*/
}
}
class Phone{
public