Pergunta

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

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

        }
 }
Foi útil?

Solução

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

Outras dicas

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()

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top