报告调用的未发生任何可检测到的状态变更的 Object.notify()Object.notifyAll()

Object.notify()Object.notifyAll() 通常用于通知其他线程发生了状态变更。 该状态变更应发生在包含 Object.notify()Object.notifyAll() 调用的同步上下文中,并且发生在调用之前。 尽管没有这样的状态变更未必就不正确,但肯定值得一探究竟。

示例:


  synchronized (this) {
    notify();
  }
  // 无状态变更
  synchronized (this) {
    notify(); // 告知可能冗余
  }