public void sim_wait(Sim_event ev) {
    if (!Sim_system.running()) {
      return;
    }
    do {
      Sim_system.wait(me, Sim_system.SIM_ANY);
      Sim_system.paused();
      restart.p();
      if (!Sim_system.running()) return;
    } while (evbuf==null);
    if ((ev != null) && (evbuf != null)) {
      ev.copy(evbuf);
      if (stat != null) {
        stat.update(Sim_stat.END_WAITING, ev.get_tag(), ev.event_time(), Sim_system.sim_clock());
        ev.set_end_waiting_time(Sim_system.sim_clock());
      }
    }
    evbuf = null;
  }