Code example for PriorityBlockingQueue

0
                100L, 
                TimeUnit.SECONDS,
                queue);
 
        @SuppressWarnings("unchecked") 
        final PriorityBlockingQueue<Runnable> singleThreadQueue = new PriorityBlockingQueue<Runnable>(10, new ComparePriority());
        singleThreadExecutorService = new ThreadPoolExecutor(1, 1, 100L, TimeUnit.SECONDS, singleThreadQueue);
 
    } 
 
    @Override 
    public int onStartCommand(final Intent intent, final int flags, final int startId) {
        handleIntent(intent);
        return START_NOT_STICKY;
    } 
 
    /** 
     * This method should be implemented to handle the execution of the background threads, it runs 
     * in the UI thread, so don't do processor heavy operations. 
     */ 
    public abstract void handleIntent(Intent intent);