aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun/opengl/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/util')
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/Animator.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/jogl/classes/com/sun/opengl/util/Animator.java b/src/jogl/classes/com/sun/opengl/util/Animator.java
index 84637433e..a10717881 100755
--- a/src/jogl/classes/com/sun/opengl/util/Animator.java
+++ b/src/jogl/classes/com/sun/opengl/util/Animator.java
@@ -53,28 +53,46 @@ import javax.media.opengl.*;
*/
public class Animator {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("Animator");
+
private volatile ArrayList/*<GLAutoDrawable>*/ drawables = new ArrayList();
private AnimatorImpl impl;
private Runnable runnable;
private boolean runAsFastAsPossible;
+ protected ThreadGroup threadGroup;
protected Thread thread;
protected volatile boolean shouldStop;
protected boolean ignoreExceptions;
protected boolean printExceptions;
/** Creates a new, empty Animator. */
- public Animator() {
+ public Animator(ThreadGroup tg) {
try {
// Try to use the AWT-capable Animator implementation by default
impl = (AnimatorImpl) Class.forName("com.sun.opengl.util.awt.AWTAnimatorImpl").newInstance();
} catch (Exception e) {
impl = new AnimatorImpl();
}
+ threadGroup = tg;
+
+ if(DEBUG) {
+ System.out.println("Animator created, ThreadGroup: "+threadGroup);
+ }
+ }
+
+ public Animator() {
+ this((ThreadGroup)null);
}
/** Creates a new Animator for a particular drawable. */
public Animator(GLAutoDrawable drawable) {
- this();
+ this((ThreadGroup)null);
+ add(drawable);
+ }
+
+ /** Creates a new Animator for a particular drawable. */
+ public Animator(ThreadGroup tg, GLAutoDrawable drawable) {
+ this(tg);
add(drawable);
}
@@ -134,6 +152,9 @@ public class Animator {
class MainLoop implements Runnable {
public void run() {
try {
+ if(DEBUG) {
+ System.out.println("Animator started: "+Thread.currentThread());
+ }
while (!shouldStop) {
// Don't consume CPU unless there is work to be done
if (drawables.size() == 0) {
@@ -152,6 +173,9 @@ public class Animator {
Thread.yield();
}
}
+ if(DEBUG) {
+ System.out.println("Animator stopped: "+Thread.currentThread());
+ }
} finally {
shouldStop = false;
synchronized (Animator.this) {
@@ -170,7 +194,11 @@ public class Animator {
if (runnable == null) {
runnable = new MainLoop();
}
- thread = new Thread(runnable);
+ if(null==threadGroup) {
+ thread = new Thread(runnable);
+ } else {
+ thread = new Thread(threadGroup, runnable);
+ }
thread.start();
}