Stop the CachedDirectoryLookupService.

It is thread safe.
767187
@Override
    public void stop(){
        if (isStarted.compareAndSet(true,false)) {
            // if you shutdown it, it can not be use anymore
            super.stop();
            ScheduledExecutorService service = this.syncService.getAndSet(newSyncService());
            service.shutdown();
            LOGGER.info("Cache sync Service is shutdown");
            for (Entry<String,ModelServiceClientCache> entry : cache.entrySet()){
               removeInstanceChangeListener(entry.getKey(),entry.getValue());
            }
            getCache().clear();
        }
    }
906908
public void stopTimer() {
		if(this.WRITE_CACHE_ENABLED) {
			if(timerWriteCache != null) {
				timerWriteCache.cancel();
			}
			if(writeTimer != null){
				writeTimer.cancel();
			}
			if(timerDeleteCache != null) {
				timerDeleteCache.cancel();
			}
			if(deleteTimer != null){
				deleteTimer.cancel();
			}
		}
	}
1210949
public synchronized void stop() {

        _coreMonitor.unregister();

        for (ServiceReg<FileMonitor> reg : _monitors.values()) {
            reg.unregister();
        }

        _monitors.clear();

        // Tidy up old location if we built it
        tidyUpMonitoredDirectory(createdMonitoredDir.get(), monitoredDirectory.get());
    }
1152544
private void stopThreadPool(ExecutorService threadPool) {
        LibraryUtils.checkCondition(threadPool == null, "Thread pool is null when calling stop");

        if (threadPool.isShutdown()) {
            logger.debug(threadPool.toString() + " is already stopped.");

        } else {

            logger.debug(threadPool.toString() + " is about to shutdown.");
            threadPool.shutdown(); // Shutdown thread pool

            try { // Wait for shutdown
                threadPool.awaitTermination(config.getThreadTerminationDelaySeconds(), TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                logger.debug("Wait thread pool termination is interrupted.");
            }

            if (!threadPool.isShutdown()) { // ShutdownNow after waiting
                logger.debug(threadPool.toString() + " is force to shutdown now.");
                threadPool.shutdownNow();
            }

            logger.debug(threadPool.toString() + " is stopped.");
        }
    }
1085294
void close(boolean cleanCache) {
        if (!this.closed) {
            this.closed = true;

            // Close storage reader (and thus cancel those reads).
            this.storageReadManager.close();

            // Cancel registered future reads and any reads pertaining to incomplete mergers.
            ArrayList<Iterator<FutureReadResultEntry>> futureReads = new ArrayList<>();
            futureReads.add(this.futureReads.close().iterator());
            synchronized (this.lock) {
                this.pendingMergers.values().forEach(pm -> futureReads.add(pm.seal().iterator()));
            }
            cancelFutureReads(Iterators.concat(futureReads.iterator()));

            if (cleanCache) {
                this.executor.execute(() -> {
                    removeAllEntries();
                    log.info("{}: Closed.", this.traceObjectId);
                });
            } else {
                log.info("{}: Closed (no cache cleanup).", this.traceObjectId);
            }
        }
    }
207506
public void shutdown(){
        synchronized(this){
            if(! isShutdown){
                if (directoryManagerFactory != null) {
                    if (directoryManagerFactory instanceof Closable) {
                        ((Closable) directoryManagerFactory).stop();
                    }
                    directoryManagerFactory = null;
                }
                if (client != null) {
                    client.close();
                    client = null;
                }
                this.isShutdown = true;
            }
        }
    }
807672
public static synchronized void stop() {
		// WsHandlerManager manager = ManagerAdmin.getWsHandlerManager();
		if (svSuperPid != null) {
			LogRepositoryManager destManager = getManager(LogRepositoryBaseImpl.LOGTYPE) ;
			((LogRepositorySubManagerImpl)destManager).inactivateSubProcess() ;
		}
			
		Logger manager = Logger.getLogger("");
		if (binaryHandler != null) {
			manager.removeHandler(binaryHandler);
			binaryHandler.stop();
			binaryHandler = null;
		}
		if (textHandler != null) {
			manager.removeHandler(textHandler);
			textHandler.stop();
			textHandler = null;
		}
		LogRepositorySpaceAlert.getInstance().stop() ;		// 694351
	}
88953
def stop(self):
        
        self.keep_reading = False
        if self.readthread is not None:
            self.readthread.join()
            self.readthread = None
418439
public boolean stop() {
        if (scheduledFuture != null && !scheduledFuture.isCancelled()) {
            scheduledFuture.cancel(DO_NOT_INTERRUPT_IF_RUNNING);
            if (LOG.isDebugEnabled()) {
                LOG.debug("{} Cache Manager stopped.", cache.getClass().getSimpleName());
            }
            return true;
        }
        return false;
    }
269826
private synchronized void stopCache()
    {
        Object[] pTables = m_setTableCacheList.toArray();
        for (Object objTable : pTables)
        {
            PTable pTable = (PTable)objTable;
            pTable.removePTableOwner(this, true);
            m_setTableCacheList.remove(pTable);
        }
        m_setTableCacheList.removeAll(m_setTableCacheList);
    }
1161470
public synchronized void stop() {
        if (!started) {
            return;
        }
        try {
            if (future != null) {
                future.cancel(true);
                future = null;
            }
            if (scheduledExecutorService != null) {
                scheduledExecutorService.shutdownNow();
                scheduledExecutorService = null;
            }
        } catch (Throwable t) {
            LOGGER.warn(t.getMessage(), t);
        } finally {
            SCHEDULED_SERVICE_MAP.remove(this);
            started = false;
        }
    }
1140391
public synchronized void stop() {
        for (final AttributeCache cache : attributeCacheMap.values()) {
            cache.stopRefresh();
        }
        for (final CommandCache cache : commandCacheMap.values()) {
            cache.stopRefresh();
        }
        if (stateCache != null) {
            stateCache.stopRefresh();
        }
        if (statusCache != null) {
            statusCache.stopRefresh();
        }
        if (POLLING_POOL != null) {
            POLLING_POOL.shutdownNow();
            POLLING_POOL = new ScheduledThreadPoolExecutor(poolSize, new TangoCacheThreadFactory());
        }
    }
823628
public final void stop()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "stop");

        synchronized (alarmLock)
        {
            if (enabled)
            {
                loaderStopTime = timeNow();
                enabled = false;
                shutdown = true;
            }
            if (loaderAlarm != null)
            {
                loaderAlarm.cancel();
                loaderAlarm = null;
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "stop");
    }
843718
def stopService(self):
        
        super(_SiteScheduler, self).stopService()
        if self.timer is not None:
            self.timer.cancel()
            self.timer = None
1206507
public void stop() {
		if (!PlatformUI.isWorkbenchRunning())
			return;
		final IWorkbench workbench = PlatformUI.getWorkbench();
		final Display display = workbench.getDisplay();
		display.syncExec(new Runnable() {
			public void run() {
				if (!display.isDisposed())
					workbench.close();
			}
		});
	}
979147
def stop(self):
        
        if getattr(self, "_jsc", None):
            try:
                self._jsc.stop()
            except Py4JError:
                # Case: SPARK-18523
                warnings.warn(
                    'Unable to cleanly shutdown Spark JVM process.'
                    ' It is possible that the process has crashed,'
                    ' been killed or may also be in a zombie state.',
                    RuntimeWarning
                )
            finally:
                self._jsc = None
        if getattr(self, "_accumulatorServer", None):
            self._accumulatorServer.shutdown()
            self._accumulatorServer = None
        with SparkContext._lock:
            SparkContext._active_spark_context = None
453968
private void stopResourceAdapter() {
        if (resourceAdapter != null)
            try {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "stop", resourceAdapter);
                ArrayList<ThreadContext> threadContext = startTask(raThreadContextDescriptor);
                try {
                    beginContext(raMetaData);
                    try {
                        ClassLoader previousClassLoader = jcasu.beginContextClassLoader(raClassLoader);
                        try {
                            resourceAdapter.stop();
                        } finally {
                            if (raClassLoader != null) {
                                jcasu.endContextClassLoader(raClassLoader, previousClassLoader);
                                classLoadingSvc.destroyThreadContextClassLoader(raClassLoader);
                            }
                        }
                    } finally {
                        endContext(raMetaData);
                    }
                } finally {
                    stopTask(raThreadContextDescriptor, threadContext);
                }

                // Cancel timers
                for (Timer timer = timers.poll(); timer != null; timer = timers.poll()) {
                    timer.cancel();
                    timer.purge();
                }

                // Cancel/release work
                workManager.stop();
            } catch (Throwable x) {
                // auto FFDC
            } finally {
                // decrement the reference count
                BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
                if (bundleContext != null) {
                    bundleContext.ungetService(contextSvcRef);
                }
            }
    }