Releasing resources of Java 7 WatchService -
i using java 7 watchservice watch directories. change directories watching. run exception:
java.io.ioexception: network bios command limit has been reached.
after 50 directories. call close() on each watchservice create before creating new one.
does know proper way release watchservice not run limit?
thanks,
dave
i think all need close()
service. know said think already, suspect missing some. instance, failing close service instances in case of exception. should treat watchservice instance other io resources , close in block; e.g.
watchservice ws = ... try { // use ... } { ws.close(); }
or using java 7 "try resource" syntax.
try (watchservice ws = ...) { // use ... }
when watchservice
closed, should free o/s level resources holds.
the other possibility have run java bug in watchservice
implementation.
Comments
Post a Comment