日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

JAVA实现inotify一样的功能_哪些操作系统支持在Java中查看本机(类似inotify)文件

發布時間:2025/4/17 64 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JAVA实现inotify一样的功能_哪些操作系统支持在Java中查看本机(类似inotify)文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

JavaDoc for java.nio.file.WatchService狀態;

The implementation … is

intended to map directly on to the native file event notification

facility where available, or to use a primitive mechanism, such as

polling, when a native facility is not available.

我認為這意味著它將嘗試一種輕量級的本機機制(如Linux上的inotify),如果不能,則進行輪詢.

那是對的嗎?

哪些操作系統可能或不可能提供這樣的設施? Linux的發行版級別真的很有用,或者我可以假設如果JVM在* unix上運行,它會受到支持嗎?

解決方法:

這應該是一個評論,但它太大了,不能發布它…

我正在查看jdk-9源代碼(也可以在jdk-8 repo中輕松搜索),但這里有一些與你的問題評論有關:

/**

* Linux implementation of WatchService based on inotify.

*

* In summary a background thread polls inotify plus a socket used for the wakeup

* mechanism. Requests to add or remove a watch, or close the watch service,

* cause the thread to wakeup and process the request. Events are processed

* by the thread which causes it to signal/queue the corresponding watch keys.

*/

class LinuxWatchService extends AbstractWatchService

對于Windows:

/*

* Win32 implementation of WatchService based on ReadDirectoryChangesW.

*/

class WindowsWatchService extends AbstractWatchService

等等..您可以在以下位置找到所有可用的實現:

jdk/src/java.base/{windows|unix|solaris|linux...}/classes/sun/nio/fs/

正如操作系統實際上支持這一點,似乎需要您查看實際的發行版.

標簽:java,linux,java-8,raspberry-pi,inotify

來源: https://codeday.me/bug/20190527/1164337.html

總結

以上是生活随笔為你收集整理的JAVA实现inotify一样的功能_哪些操作系统支持在Java中查看本机(类似inotify)文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。