Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

June 20, 2012

InvalidMonitorStateException

This exception is thrown when we call wait(), notify() or notifyAll() methods from any object when we are not having lock on that object.

This exception is a sub-class of RuntimeException. So we donot need to handle this.
Also this is the reason why the signatures of  wait(), notify() or notifyAll() do not have this exception declared .

Thread.run() and Thread.start()

Thread.start() essentially calls run() method only.
If we call Thread.run() directly, it will be executed in the same thread and a new thread would not be created.
So the purpose of multithreading is not fulfilled.