protected synchronized ExecutorService getService ( ) { if ( service == null ) { // System.out.println("creating an executor service with a threadpool of size " + threadPoolSize); service = Executors . newFixedThreadPool ( threadPoolSize , new ThreadFactory ( ) { private int count = 0 ; @ Override public Thread newThread ( Runnable r ) { Thread t = new Thread ( r , "tile-pool-" + count ++ ) ; t . setPriority ( Thread . MIN_PRIORITY ) ; t . setDaemon ( true ) ; return t ; } } ) ; } return service ; }
Subclasses may override this method to provide their own executor services . This method will be called each time a tile needs to be loaded . Implementations should cache the ExecutorService when possible .