How many newWatchService can I make ?
try{
for(Path path : PathList) {
watcher = path.getFileSystem().newWatchService();
} catch (IOException e) {
log.error(e);
}
}
--> result: IOExeption: too many open files...
How many newWatchService can I make ?
try{
for(Path path : PathList) {
watcher = path.getFileSystem().newWatchService();
} catch (IOException e) {
log.error(e);
}
}
--> result: IOExeption: too many open files...
Copyright © 2021 Jogjafile Inc.
I think you are supposed to create only one watcher service, but register [m]any paths to it.
As per the example given by Oracle docs (https://docs.oracle.com/javase/tutorial/essential/io/walk.html), there is only one watch service created, as a member variable of WatchDir class. Note the "this.watcher"
elsewhere in the class...
The same service is used for registering all paths inside a given folder recursively.
Finally, the registration happens here...