Question

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

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

        }
 }
Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top