Code example for ConcurrentLinkedQueue

Methods: size

0
    /** 
     * Schedule a new download worker. 
     */ 
    public boolean schedule(Runnable r) {
        queue.add(r);
        if (threads.size() == 0) {
            handler.removeCallbacks(wakeUpThread);
            wakeUpThread.run();
            return true; 
        } 
        return false; 
    } 
 
    private Runnable wakeUpThread = new Runnable() {
        @Override 
        public void run() { 
            Runnable r = queue.poll(); 
            if (r == null) { 
                return; 
            }