public void execute(Runnable runnable){
synchronized (lock) {
    pending=runnable;
    lock.notifyAll();
  }
}

public void execute ( Runnable runnable ) { synchronized ( lock ) { pending = runnable ; lock . notifyAll ( ) ; } }
queues runnable for execution . will be executed as soon as the current runnable has terminated . if there is no current executable , will be executed immediately ( in the thread created by this instance ) . if this method is called again before the current runnable is executed , runnable will be discarded in favor of the new .
