Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if thread dies finally won't execute

 
Rick Reumann
Ranch Hand
Posts: 281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One place I have in my notes I have the only thing stopping finally is system.exit() but I also have in another portion of notes that a thread dying could also stop it.
I take it this means that if a Thread object is started with a finally in it and it happens to be a Daemon thread, that it's possible that the main could die and terminate this daemon thread before it's finally would get executed? Is this correct?
Thanks.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... Seems like another perfect chance to use the compiler to answer a question. Check out this code:

I guess this lets you draw your own conclusions, but it sure looks like you're right to me.
Corey
 
Rick Reumann
Ranch Hand
Posts: 281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Corey! And you are right I should have written code to test this. I apologize. Scrambling around through my many notes here on my last day of studying has me a bit frazzled. Thanks for not flaming my slackness too badly
Your code was perfect.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic