示例#1
0
  private void paintAnimations(Graphics2D g2d) {

    LinkedList<Animation> toRemove = new LinkedList<Animation>();
    // get all the animations you can, forget about the ones that are about to be added
    animationLock.lock();
    List<Animation> toPaint = (List<Animation>) animations.clone();
    animationLock.unlock();
    for (Animation x : toPaint) {
      if (x.isOver()) toRemove.add(x);
      else x.step(g2d);
    }

    animations.removeAll(toRemove);
  }