1 package net.sf.openrocket.simulation.listeners;
3 import java.util.Collection;
5 import net.sf.openrocket.simulation.FlightEvent;
6 import net.sf.openrocket.simulation.SimulationStatus;
7 import net.sf.openrocket.simulation.exception.SimulationCancelledException;
11 * A simulation listener that throws a {@link SimulationCancelledException} if
12 * this thread has been interrupted. The conditions is checked every time a step
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 public class InterruptListener extends AbstractSimulationListener {
19 public static final InterruptListener INSTANCE = new InterruptListener();
22 public Collection<FlightEvent> stepTaken(SimulationStatus status)
23 throws SimulationCancelledException {
25 if (Thread.interrupted()) {
26 throw new SimulationCancelledException("The simulation was interrupted.");