Code example for ConcurrentLinkedQueue

0
 
    private final Handler handler;
 
    // @formatter:off 
    private final ConcurrentLinkedQueue<DownloadThread> threads = 
        new ConcurrentLinkedQueue<DownloadThread>();
    private final ConcurrentLinkedQueue<Runnable> queue = 
        new ConcurrentLinkedQueue<Runnable>();
    // @formatter:on 
 
    /** 
     * Associate a new DownloadManager instance with a thread's message queue. 
     */ 
    public DownloadManager(Handler handler) {
        this.handler = handler;
    } 
 
    /** 
     * Schedule a new download worker. 
     */ 
    public boolean schedule(Runnable r) {