diff options
author | Sven Gothel <[email protected]> | 2011-02-26 21:43:20 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-02-26 21:43:20 +0100 |
commit | 76444dce2b678a7f6769564abac4f8a73f414609 (patch) | |
tree | 09358c0a48715c69e7e8f511cf3d9be729177509 /src/jogl/classes/jogamp/opengl | |
parent | 77546f8968779fbdcfe58f89c6924803642889c7 (diff) |
Clean/Fix: Threading Code
- Remove unsafe double checked locking
- Annotate safe double checked locking (volatile)
- use 'static final' if possible
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLWorkerThread.java | 7 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/ThreadingImpl.java | 8 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java | 8 |
3 files changed, 6 insertions, 17 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java index e57cbe0bc..ac9655fbb 100644 --- a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java +++ b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java @@ -40,7 +40,6 @@ package jogamp.opengl; import java.lang.reflect.InvocationTargetException; -import java.security.*; import java.util.*; import javax.media.opengl.*; @@ -69,9 +68,11 @@ public class GLWorkerThread { /** Should only be called by Threading class if creation of the GLWorkerThread was requested via the opengl.1thread system - property. */ + property. <br> + * Start the GLWorkerThread iff not started yet! + */ public static void start() { - if (!started) { + if (!started) { // volatile: ok synchronized (GLWorkerThread.class) { if (!started) { lock = new Object(); diff --git a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java index d63699aad..67a950185 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java +++ b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java @@ -203,13 +203,7 @@ public class ThreadingImpl { throw new InternalError(); case WORKER: - if (!GLWorkerThread.isStarted()) { - synchronized (GLWorkerThread.class) { - if (!GLWorkerThread.isStarted()) { - GLWorkerThread.start(); - } - } - } + GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking try { GLWorkerThread.invokeAndWait(r); } catch (InvocationTargetException e) { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index a681c5b8f..dd493f5ee 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -103,13 +103,7 @@ public class AWTThreadingPlugin implements ThreadingPlugin { break; case ThreadingImpl.WORKER: - if (!GLWorkerThread.isStarted()) { - synchronized (GLWorkerThread.class) { - if (!GLWorkerThread.isStarted()) { - GLWorkerThread.start(); - } - } - } + GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking try { GLWorkerThread.invokeAndWait(r); } catch (InvocationTargetException e) { |