public void run() { try { for (; ; ) { Target t = null; synchronized (pending) { while (pending.size() == 0) pending.wait(); t = (Target) pending.removeFirst(); } t.show(); } } catch (InterruptedException x) { return; } }
public void printFinishedTargets() { // 打印finisedTargets队列中的任务 try { for (; ; ) { Target target = null; synchronized (finishedTargets) { while (finishedTargets.size() == 0) finishedTargets.wait(); target = (Target) finishedTargets.removeFirst(); } target.show(); } } catch (InterruptedException x) { return; } }