我正忙于编写一个使用java.nio.file.WatchService
.
watchKey = watchService.take();
for (WatchEvent<?> event : watchKey.pollEvents()) {
// Handle the events
}
watchKey.reset();
该事件被轮询并正确处理。
下次我打电话时问题来了watchService.take()
在处理事件期间,发生了更多事件,因此第一个事件是 type StandardWatchEventKinds.OVERFLOW
。
如何获取这些事件或阻止事件丢失?重要的是我不会丢失任何事件。