Frage

When to invoke super.wait(), something like below -

synchronized (this)
      {
        while (true)
        {
          try
          {
            super.wait();
          }
          catch (InterruptedException e)
          {
            return;
          }

        }
 }
War es hilfreich?

Lösung

Object.wait() is declared final and cannot be overridden. So super.wait() always means just wait() but is a bit longer.

Andere Tipps

wait() must be called on the same object on which it it synchronized otherwise it will result in java.lang.IllegalMonitorStateException

It should be this.wait()

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top