public void windowClosing(WindowEvent e) { animator.stop(); System.out.println("Exiting"); System.exit(0); } });
public void windowClosing(WindowEvent e) {    new Thread(new Runnable() { public void run() { animator.stop(); System.exit(0); } }).start(); } });
  public static void main(String[] argv)  {        Frame frame = new Frame("Cg demo (runtime_ogl_vertex_fragment)");    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());    canvas.addGLEventListener(new runtime_ogl_vertex_fragment());    // Use debug pipeline    canvas.setGL(new DebugGL(canvas.getGL()));    frame.add(canvas);    frame.setSize(512, 512);    final Animator animator = new Animator(canvas);    frame.addWindowListener(new WindowAdapter() {      public void windowClosing(WindowEvent e) {        animator.stop();        System.out.println("Exiting");        System.exit(0);      }    });    frame.show();    animator.start();    // and all the rest happens in the display function...  }