@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(); }
@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; }