Code example for ExecutorService

Methods: awaitTermination, shutdown, shutdownNow

0
    } 
 
    public void shutdown() { 
        // via 
        // http://gurimmer.lolipop.jp/daihakken/2012/01/27/javaexecutorservice%E3%81%AE%E6%AD%A3%E3%81%97%E3%81%84%E7%B5%82%E4%BA%86shutdown%E3%81%AE%E4%BB%95%E6%96%B9/ 
        loading_service.shutdown();
        try { 
            if (!loading_service.awaitTermination(1000, TimeUnit.MILLISECONDS)) {
                loading_service.shutdownNow();
            } 
        } catch (InterruptedException e) {
            e.printStackTrace();
            loading_service.shutdownNow();
        } 
        clearCache(); 
    } 
 
    private void queueJob(ImageView image_view, String image_url, Activity activity) {
        loading_service.submit(new LoadingHandler(image_view, image_url, activity));
    }