Object.wait()
is declared final and cannot be overridden.
So super.wait()
always means just wait()
but is a bit longer.
When to call wait() on super [closed]
-
18-07-2023 - |
Question
When to invoke super.wait()
, something like below -
synchronized (this)
{
while (true)
{
try
{
super.wait();
}
catch (InterruptedException e)
{
return;
}
}
}
Solution
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