// Only call this from a downloader thread. // If the active queue is full, the downloader will // block until a spot frees up. public void addActive(SegDownloader s) { try { active.put(s); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public synchronized void addStopped(SegDownloader s) { try { bstopped.put(s); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// Wait on this download to finish. Implemented by trying to push something to the // blocking queue. Since the pusher waits until the queue has space, only empty // the queue if the download is finished. public void waitForMe() { waiters++; try { waitToken.put(true); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }