Hacker News new | ask | show | jobs
by kevinconaway 2971 days 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.h...

[1] https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.h...

1 comments

You are right, editted.
As the article itself says, you're unlikely to write correct code if you use these language features. :)