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

Unable to understand statement?

 
manish ghildiyal
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got this from Oracle java docs
(http://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html)

Many methods that throw InterruptedException, such as sleep, are designed to cancel their current operation and return immediately when an interrupt is received.


.....so when a thread is in dormant/blocked state(due to invocation of sleep method)
and it is interrupted then sleep method throws InterruptedException....so sleep method either returns as stated above or throws exception...how can
both happen together?

Manish
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manish ghildiyal wrote:
I got this from Oracle java docs
(http://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html)

Many methods that throw InterruptedException, such as sleep, are designed to cancel their current operation and return immediately when an interrupt is received.


.....so when a thread is in dormant/blocked state(due to invocation of sleep method)
and it is interrupted then sleep method throws InterruptedException....so sleep method either returns as stated above or throws exception...how can
both happen together?



I think you may be too literal in your interpretation. In this case, I think that it is safe to assume that the word "return" does not mean the literal execution of the "return" keyword; it simply means "returning back from the method" -- and that includes throwing an exception.

Henry
 
manish ghildiyal
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry,

Thanks for clarification.

Manish

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic