线程互斥

public void method1() {  synchronized(this) {  ... } } 等同于 public synchronized void method1() { ... }

public void method2() {  synchronized(XXXX.class) {  ... } } 等同于 public static synchronized void method2() { ... }

synchronized + 同对象 才可 互斥 锁不是放在线程上的,放在共享资源内部的。

相关文章:

  • 2021-08-31
  • 2021-12-09
  • 2022-01-16
  • 2021-05-30
  • 2021-12-18
  • 2021-10-17
  • 2021-10-11
  • 2022-01-23
猜你喜欢
  • 2021-06-09
  • 2021-08-31
  • 2021-07-06
  • 2021-07-29
  • 2021-04-30
  • 2021-10-25
  • 2021-09-03
相关资源
相似解决方案