3 ms·
> calling isInterrupted() actually clears the interrupted bit. Thats incorrect. Calling Thread#interrupted[0] clears the interrupt status and returns true if
by kevinconaway 8y ago
> calling isInterrupted() actually clears the interrupted bit.
Thats incorrect. Calling Thread#interrupted[0] clears the interrupt status and returns true if the current thread was interrupted. Thread#isInterrupted()[1] only returns the value of the interrupt status on the thread receiving the method call. The interrupt status is unaffected by that method call.
[0] https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#interrupted-- https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.h...
[1] https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#isInterrupted-- https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.h...
- anameaname 8y agoYou are right, editted.
- crunchlibrarian 8y agoAs the article itself says, you're unlikely to write correct code if you use these language features. :)