wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads and Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads and Exceptions" Watch "Threads and Exceptions" New topic

Threads and Exceptions

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 236

I am confused with thread exceptions.
can someone please explain the difference in the exceptions InterruptedException, IllegalMonitorStateException, IllegalThreadStateException.

which exception th wait() method should be wrapped in?
Ramamoorthy Periasamy
Ranch Hand

Joined: Feb 06, 2006
Posts: 30
Vepa Sritej
Ranch Hand

Joined: Jul 31, 2006
Posts: 42
InterruptedException is thrown when any thread is interrupted while it has executed sleep() or wait().
IllegalMonitorState Exception is thrown when any thread executes wait() without holding a lock on an object.

InterruptedException must be handled via try..catch or must be declared in the method defintion. IllegalMonitorState is thrown by JVM..

tej<br /> <br />SCJP 1.5 --75%<br />SCWCD --89%<br />SCBCD/Web Services!! Yet to Decide
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 236
what about IllegalThreadStateException?
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
When the start() method is called twice on single thread then it throws IllegalThreadStateException.

I agree. Here's the link: http://aspose.com/file-tools
subject: Threads and Exceptions
It's not a secret anymore!