Java 7 WatchService是否适合其他任何人? [英] Is Java 7 WatchService Slow for Anyone Else?
问题描述
WatchService看起来是一项很棒的技术,但它在我测试过的OS X和Linux系统上运行速度太慢了。为了增加对伤害的侮辱,它似乎也没有得到所有事件的通知。
WatchService looks like a great technology but its been too slow to be useful on the OS X and Linux systems I've tested on. To add insult to injury, it doesn't seem to get notified of all events either.
这是我自己的代码和Oracle的规范示例的情况。 ( http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java )
This is the case both with my own code and the canonical example from Oracle. (http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java)
我认识到OS X OpenJDK端口不确定此功能(参见 https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port+Project+Status )
I recognize that the OS X OpenJDK port is unsure of this functionality (see https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port+Project+Status)
有没有人在制作中成功使用它?
Has anyone been using this in production with success?
推荐答案
如果我改变了,我有更好的响应时间
I have much better response times if I change
folder.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
到
folder.register(watcher, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY}, SensitivityWatchEventModifier.HIGH);
这篇关于Java 7 WatchService是否适合其他任何人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!