Code example for LinkedBlockingQueue

0
    private static final int CORE_POOL_SIZE = 5;
    private static final int MAXIMUM_POOL_SIZE = 10;
    private static final int KEEP_ALIVE = 10;
 
    private static final LinkedBlockingQueue<Runnable> sWorkQueue =
            new LinkedBlockingQueue<Runnable>();
 
    private static final ThreadFactory sThreadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1); 
 
        public Thread newThread(Runnable r) { 
            return new Thread(r, "AsyncTaskEx #" + mCount.getAndIncrement()); 
        } 
    }; 
 
    private static final ThreadPoolExecutor sExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE,
            MAXIMUM_POOL_SIZE, KEEP_ALIVE, TimeUnit.SECONDS, sWorkQueue, sThreadFactory);
 
    private static final int MESSAGE_POST_RESULT = 0x1;
    private static final int MESSAGE_POST_PROGRESS = 0x2;
    private static final int MESSAGE_POST_CANCEL = 0x3;