Package sim.engine

Class WeakStep

java.lang.Object
sim.engine.WeakStep
All Implemented Interfaces:
Serializable, Steppable

public class WeakStep extends Object implements Steppable
WeakStep is a wrapper for steppable objects in the situation where we only want the schedule to tenuously hold onto the steppable object -- that is, if everyone else has forgotten about the object, the schedule should as well. This is commonly the case for inspectors and other kinds of windows which might be closed by the user without any way to get back to the schedule and remove themselves. You schedule a Steppable weakly something like this:
mySchedule.schedule(new WeakStep(mySteppable));

A WeakStep can also wrap a Steppable you plan on scheduling repeating. You'd do it along these lines:
WeakStep weak = new WeakStep(mySteppable);
Stoppable stop = mySchedule.scheduleRepeating(weak);
weak.setStoppable(stop);
In this case, when the underlying Steppable is garbage-collected, then the schedule will automatically stop repeatedly stepping it. Note that the Stoppable is not stored weakly.
See Also:
  • Constructor Details

  • Method Details