public void run() { try { while (true) { Runnable cur; synchronized (q) { while ((cur = q.poll()) == null) q.wait(); } cur.run(); cur = null; } } catch (InterruptedException e) { } }