Пример #1
0
  @Override
  public void run() {
    while (!stop) {
      DataVector<O> output = process();

      List<O> list = output.getVector();
      if (list == null || list.size() == 0) {
        stop = true;
      } else {
        Iterator<O> iter = output.getVector().iterator();
        O data;
        for (Link<O> exit : exits) {
          try {
            if (iter.hasNext()) {
              data = iter.next();
              exit.getQueue().putFirst(data);
            } else {
              break;
            }
          } catch (InterruptedException ie) {
            logger.log(Level.WARNING, "Impossible to put a Data in an exit queue", ie);
          }
        }
      }
    }
    stop();
  }
Пример #2
0
 @Override
 public void stop() {
   try {
     O killer = createO();
     Pilot pilot = new Pilot();
     pilot.setExtinguisher(true);
     killer.setPilot(pilot);
     for (Link<O> exit : exits) {
       exit.getQueue().putFirst(killer);
     }
   } catch (Exception e) {
     logger.log(Level.SEVERE, "Impossible to instanciate O", e);
   }
   this.stop = true;
 }
Пример #3
0
 public void start() {
   for (Link<O> link : exits) {
     link.ignite();
   }
   thread.start();
 }