views:

59

answers:

3

I have an application with a JOGL component. When it shuts down using System.exit(0), I frequently get the exception:

java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
at sun.java2d.Disposer.run(Disposer.java:125)
at java.lang.Thread.run(Thread.java:619)

I have seen this question http://stackoverflow.com/questions/2873449/occasional-interruptedexception-when-quitting-a-swing-application but I don't have any non-daemon threads running. I'm wondering if the underlying JOGL code is continuously putting events in the swing event queue which could cause this error since the swing app will only shutdown properly when the event queue is empty.

Is there a way to shutdown more cleanly? Maybe somehow stop the JOGL main loop (I'm using a 3rd party tool, nasa worldwind, so I don't necessarily have access to the main Animator running the app).

EDIT: It turns out this was not an openGL problem at all. OpenGL was being properly shutdown and there was just a race in a shutdown hook I had running. Thanks.

+2  A: 

make sure you stop everything you started before calling System.exit();

if you start an animator using

Animator anim = new Animator(canvas); anim.start();

be sure to call anim.stop() before you exit your program

Nikolaus Gradwohl
I am not starting any of the animators, but it's possible that the worldwind openGL code is. I'm trying to track that down. Should the display method in the GLAutoDrawable have a check that if it's shutdown to just return from the method?
Jeff Storey
could help, give it a try
Nikolaus Gradwohl
+2  A: 

From JOGL wiki page

import java.awt.Frame;
import com.sun.opengl.util.Animator;

// ...

frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            exit();
        }
        });

// ...

public static void exit(){
    animator.stop();
    frame.dispose();
    System.exit(0);
}
slf
A: 

It turns out this was not an openGL problem at all. OpenGL was being properly shutdown and there was just a race in a shutdown hook I had running. Thanks.

Jeff Storey