This applies to the Path # register method. If a thread is working with a block containing this method, and another thread interrupts it in advance. Then it turns out that the method clears the interrupt status.
No, where the document mentions that it clears the thread interrupt status.
To replicate
import java.io.*; import java.nio.file.*; import static java.nio.file.LinkOption.*; import static java.nio.file.StandardWatchEventKinds.*; import java.nio.file.attribute.*; public class WatchDir { private final WatchService watcher; private void register(Path dir) throws IOException {
You may notice above that the interrupt status is cleared after calling the register function. Output Example:
--------------------BUG------------------- Interrupt Status: true before making call to Path
This problem arose because the service was found to be active even after a shutdown request. Any ideas?
edit: It turns out this only happens on Windows and Linux. The Mac behaves as expected. My OS: Win 7 64-bit. JDK 1.7.0_11. Also found by: Ubuntu 14.04 Java 1.7.0_45-b18
java multithreading concurrency interrupt
Jatin
source share