summaryrefslogtreecommitdiffstats
path: root/src/demos/cg
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/cg')
-rw-r--r--src/demos/cg/runtime_ogl/cgGL_vertex_example.java11
-rw-r--r--src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java18
2 files changed, 21 insertions, 8 deletions
diff --git a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
index 16c3e1a..ec2cb9a 100644
--- a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
+++ b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
@@ -267,8 +267,15 @@ public class cgGL_vertex_example implements GLEventListener
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
- animator.stop();
- System.exit(0);
+ // Run this on another thread than the AWT event queue to
+ // make sure the call to Animator.stop() completes before
+ // exiting
+ new Thread(new Runnable() {
+ public void run() {
+ animator.stop();
+ System.exit(0);
+ }
+ }).start();
}
});
frame.show();
diff --git a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
index 38ab297..3ceabc0 100644
--- a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
+++ b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
@@ -74,12 +74,18 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
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);
- }
- });
+ public void windowClosing(WindowEvent e) {
+ // Run this on another thread than the AWT event queue to
+ // make sure the call to Animator.stop() completes before
+ // exiting
+ new Thread(new Runnable() {
+ public void run() {
+ animator.stop();
+ System.exit(0);
+ }
+ }).start();
+ }
+ });
frame.show();
animator.start();