- 博客(2)
- 收藏
- 关注
原创 关于synchronized同步方法
修饰同步方法:作用于当前实例加锁,进入同步代码前要获得当前实例的锁。public class TestThread { public synchronized void car1(){ System.out.println(Thread.currentThread()+"获得资源"); try { Thread.currentThread().sleep(3000); } catch (InterruptedExcepti
2022-05-04 15:42:45
445
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人