• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in exception handling????

 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

plz help me by providing suitable reasoning for the behavoir exhibited by this code:


why does controll goes directly to 2) from 1)???

thanx,
amit
[ May 11, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) First, your throw exception in the catch throws it up to the JVM and not to the try catch, so the catch of Exception will not be run.
2) Finally is always run. So after the catch of the InterruptedException, then it runs the finally code.

Mark
 
Amol Fuke
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since its a exception of type InteruptedException it will be caught at line 1.Had the exception be of Exception other than InterruptedException then it will be caught in Exception clause.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic