public void shutdown() {
        if ( null != executor ) {
            final CountDownLatch beginLatch = new CountDownLatch(threads);
            final CountDownLatch finishLatch = new CountDownLatch(threads);
            for ( int i = 0; i < threads; i++ ) {
                executor.submit(new Runnable() {

                    @Override
                    public void run() {
                        beginLatch.countDown();
                        try {
                            beginLatch.await();
                        } catch (InterruptedException e) {
                        }
                        try {
                            dynamicCaseProcessor.cleanupResourcePerThread(context);
                        } catch (Throwable ignore) {
                        } finally {
                            finishLatch.countDown();
                        }
                    }
                });
            }
            try {
                finishLatch.await();
            } catch (InterruptedException e) {
            }
            executor.shutdownNow();
        }
    }