简体   繁体   English

JNotify与轮询

[英]JNotify vs Polling

I am working with Java 6 and can not use Watch Service. 我正在使用Java 6,不能使用监视服务。 I am looking for an alternative to polling. 我正在寻找一种替代投票的方式。 So how is JNotify different from polling? 那么JNotify与轮询有何不同? Or does JNotify uses polling? 还是JNotify使用轮询?

JNotify is using the native OS support for file system notifications. JNotify正在使用本机OS支持的文件系统通知。 on Linux it's using INotify (which is the inspiration for it's name), on Windows it's using ReadDirectoryChangesW and on Mac it's using FSEventStream API. 在Linux上,它使用INotify(这是其名称的灵感);在Windows上,它使用ReadDirectoryChangesW;在Mac上,它使用FSEventStream API。 I started JNotify around 2005, long before the JVM supported file system notifications. 我是在2005年左右开始JNotify的,那早在JVM支持文件系统通知之前。 Today the recommended way is to use the JVM support, but if you can't rely on that is a good alternative. 今天,推荐的方法是使用JVM支持,但是如果您不能依靠它,那是一个不错的选择。

One thing to remember is that JNotify is using the OS support which is sometimes no great. 要记住的一件事是,JNotify使用的是操作系统支持,有时效果不佳。 in some cases file system events gets dropped by the OS and there is not much you can do about it. 在某些情况下,操作系统会丢弃文件系统事件,您对此无能为力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM