title: How to shutdown Ehcache CacheManager in standalone application
body: <p>I have a simple API that my clients use in a standalone application. Behind the scenes my API uses Ehcache for performance. </p>
  
  <p>Everything works fine except that my client needs to invoke a <code>shutdown()</code> method in my API to  invoke <code>CacheManager.shutdown()</code> without which Ehcache continues to run in the background even though the main thread is completed.</p>
  
  <p>Is there a way I can avoid this extra <code>shutdown()</code> call for my client?</p>
  
  <p>I tried using @PreDestroy Spring annotation to invoke this call, but it didn't work?</p>
  
  <p>Here I am adding a sample client program.</p>
  
  <pre><code>public class ClientApp{
      @Autowired
      private IClientService service;
  
      public static void main(String[] args){
          try{
              service.getClients();
              ...
          } finally {
              service.shutdown(); // to shutdown the cache background thread
          }
      }
  }
  </code></pre>
  
  <p>In ClientServiceImpl.java, I have the following lines</p>
  
  <pre><code>public void shutdown(){
      LOGGER.info("Shutting the cache down...");
      ehcacheManager.shutdown();
  }
  </code></pre>