예제 #1
0
 public void run() {
   try {
     while (true) {
       Runnable cur;
       synchronized (q) {
         while ((cur = q.poll()) == null) q.wait();
       }
       cur.run();
       cur = null;
     }
   } catch (InterruptedException e) {
   }
 }
예제 #2
0
 public void defer(Runnable r) {
   synchronized (q) {
     q.add(r);
     q.notify();
   }
 }