Issue with WatchService on Mac OS 10.9.1 using Oracle JDK 1.7.0_51

Alan Bateman Alan.Bateman at oracle.com
Wed Jan 15 09:53:24 PST 2014


On 15/01/2014 17:30, Christian Schlichtherle wrote:
> :
>
> Now if I comment out the call to Thread.sleep(250), then the background thread may miss the modification of the file „foo" on the foreground thread approx. 50% of the time.
>
> So I wonder if I am using this API wrong or is this a bug?
>
> Furthermore, I found the Mac OS X implementation of the WatchService to be a PollingWatchService. Is there a way to configure the polling interval? It seems to be about ten seconds or so, figured from doing trial-and-error tests.
>
At some point we need to replace this with a native implementation (OS X 
is currently the only implementation where we always using the polling 
implementation).

So I'm curious where foo is created, is is created just before the code 
that you pasted in? I'm just wondering if the append results in the 
modified time changing or not.

As regards changing the interval then it can be done by specifying a 
modifier of com.sun.nio.file.SensitivityWatchEventModifier.HIGH when 
registering the directory. It's not otherwise configurable.

-Alan


More information about the nio-discuss mailing list