public synchronized boolean waitForState(int state) {
      switch (state) {
        case Processor.Configured:
          p.configure();
          break;
        case Controller.Realized:
          p.realize();
          break;
        case Controller.Prefetched:
          p.prefetch();
          break;
        case Controller.Started:
          p.start();
          break;
      }

      while (p.getState() < state && !error) {
        try {
          wait(1000);
        } catch (Exception e) {
        }
      }
      // p.removeControllerListener(this);
      return !(error);
    }