animator.stop problem

hello, i have a question about the animator.stop
function:

how can i reach a clean quit in jogl application

public void keyReleased(KeyEvent key) {
switch (key.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
system.exit(0);
break;

this exit didnt call the windowclosing and i have no idea
how to do it!
(after 3-5 time i run my application,the pc slows completly down,i think the exit didnt work good)

what can i do?

public static void main(String[] args) {

final FPSAnimator animator = new FPSAnimator(canvas,60 );
animator.setRunAsFastAsPossible(true);

    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing() {
      runExit(animator);
    }
  });


private static void runExit(final FPSAnimator animator) {
new Thread(new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
}

Use a shutdown hook.

Spawn a new thread to call System.exit(). We’ve found that calling exit() from the Event Dispatch Thread doesn’t work on all platforms. There are examples of this in the source code for the JOGL demos.

[quote]Spawn a new thread to call System.exit(). We’ve found that calling exit() from the Event Dispatch Thread doesn’t work on all platforms. There are examples of this in the source code for the JOGL demos.
[/quote]
ahhh, okay … i understand

much thanks :slight_smile: