public void run(){
  while (true) {
    Runnable r=null;
synchronized (queue) {
      while (queue.isEmpty()) {
        try {
          queue.wait();
        }
 catch (        java.lang.InterruptedException e) {
          e.printStackTrace();
        }
      }
      r=queue.remove(queue.size() - 1);
    }
    try {
      r.run();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

public void run ( ) { while ( true ) { Runnable r = null ; synchronized ( queue ) { while ( queue . isEmpty ( ) ) { try { queue . wait ( ) ; } catch ( java . lang . InterruptedException e ) { e . printStackTrace ( ) ; } } r = queue . remove ( queue . size ( ) - 1 ) ; } try { r . run ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } }
start going . this function locks the queue , dequeues and item , unlocks the queue , and calls run on the object that was dequeued . if no object was on the queue , it waits on the queue . this function never exits .
