File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads trying to get InterruptedException

 
shuba gopal
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am trying to get InterruptedException during thread execution. I expected that t.join() after t.start() will throw this exception. But the program runs without exception.

 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please indent your code correctly; your inconsistent indentation makes it difficult to read. Have you seen the circumstance in which this exception can occur in the InterruptedException documentation? It doesn't say anything about join(). Have you read about interruption in the Java™ Tutorials?

I shall move this thread as too difficult for "beginning".
 
shuba gopal
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is actually part of a question that I have reconstructed from my memory. I am not sure I can quote the exact source. According to the solution, for "Interrupted" to be printed, t.join() had to be used.
 
shuba gopal
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell, sorry about the indentation.
 
Paul Clapham
Sheriff
Pie
Posts: 20208
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't imagine why thread A trying to join thread B would cause thread A to be interrupted. And according to your test, it isn't. So the world is working as it should.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic