Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Threads and Exceptions

 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InterruptedException
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about IllegalThreadStateException?
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the start() method is called twice on single thread then it throws IllegalThreadStateException.

Regards,
Praveen
http://www.javahub.co.nr
http://praveen.awardspace.com
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic