Netflix/curator — pull request #22 by cb372 (2012-01-20 09:14:58+00:00)
Title: Make ServiceCache close itself down properly.

ServiceCache leaves a thread and an ExecutorService lying around even after its `close()` method has been called. This was causing me problems because it prevents the JVM from shutting down.

Commit message:

Fixed ServiceCache.close() to interrupt the cache's worker thread and
shut down its ExecutorService.

Note that the worker thread is interrupted *after* all the listeners are
removed. So if the ZK watch triggers and the worker thread wakes up
while the cache is being closed, it may send a cacheChanged() event to
only some of the listeners.

Because of this, it may be better to interrupt the worker thread (and
make sure it's dead) *before* removing the listeners.