Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Java 7 WatchService Slow for Anyone Else?

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.

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)

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?

like image 386
sbook Avatar asked Mar 06 '12 17:03

sbook


1 Answers

I have much better response times if I change

folder.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY); 

to

folder.register(watcher, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY}, SensitivityWatchEventModifier.HIGH); 
like image 133
makc Avatar answered Sep 20 '22 12:09

makc