Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法在一个小示例中重现该问题,但是如果 WatchService 和s 相同,是否可以WatchKeys为一个注册两个不同的?PathKind<?>
WatchKeys
Path
Kind<?>
例如,如果父目录内容发生变化?
是的,如果您在注册第二个之前取消旧的。
由于未决事件(如果有)仍然处于未决状态,并且可以在取消键后通过调用 pollEvents 方法来检索,这似乎是合理的。
但是,取消的 WatchKey 永远无效。