• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cases in Finally block doesn't get executed.  RSS feed

 
vicky Aggarwal
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there other cases in which finally doesn't execute rather than
1 System.stop();
2 Stoping thread from outside the block.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.stop() or System.exit()?

anyway look at this thread : http://www.coderanch.com/t/409527/java/java/finally-code-not-executed

here is the example for peter statement:
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A meteorite hits the server?
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:A meteorite hits the server?
Been done before

I still miss Stan James.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Been done before

Ok, how about this...someone is trying to steal $100 million from the Bellagio, and they set off an EMP?
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not seen that film, I am afraid.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's always the good old infinite loop:
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we read the words then this is true, but anyway, that was not he's asking...
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think we really know what he meant asking. An infinite loop is a perfectly valid answer to what he did ask. And it may very well be what he wanted, as well.

Other possibilities include thread deadlock, and reading from a socket input stream which is never written to (and has no timeout). Or attempting to solve a problem whose computational complexity requires more than the age of the universe to solve. Or for that matter, Thread.sleep(Integer.MAX_INTEGER) is long enough for most purposes.
 
vicky Aggarwal
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zandis Murāns wrote:If we read the words then this is true, but anyway, that was not he's asking...


I am sure i was not asking this, because i never thought of such scenarios. :D
But it always gud to know new things.

Thank you all for your inputs. :beerchug:
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is strange, since it looks like the whole point of your question was to learn about things you hadn't thought of already.
 
Greg Reeder
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if this code is written;



will that finally statement be reached due to throwing a new exception?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it yourself?
 
Greg Reeder
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I'll be , you do. Shoulda tried that before hand.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!