wait(), notify() and notifyAll() should be called only if the current thread is
the owner of the object, else it throws illigalmonitorstate exception
check out the java API for wait notify and notifyall in the object class.
This method should only be called by a thread that is the owner of this object's
monitor. A thread becomes the owner of the object's monitor in one of three
ways:
By executing a synchronized instance method of that object.
By executing the body of a synchronized statement that synchronizes on the
object.
For objects of type Class, by executing a synchronized static method of that
class.