This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by Murgan Sub: Which is better for a check in "while" isInterrupted or interrupted()
For this particular example, it probably won't make much difference, but there are some subtle differences between the Thread methods interrupted() and isInterrupted(). First of all, the method interrupted() is a static method. More importantly, however, the interrupted() method clears the interrupted status of the thread. Therefore, if a thread was interrupted, calling interrupted() once would return true, while a second call to it would return false. The isInterrupted() method, on the other hand is neither static nor does it affect the interrupted status of the thread. You'll have to think about how you'd like your application to run to determine which you'd prefer to use. Corey