jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [5/6] jena git commit: JENA_1029: Comment about threading and about recursive initialization.
Date Fri, 18 Sep 2015 22:29:45 GMT
JENA_1029: Comment about threading and about recursive initialization.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/a0a2d0d0
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/a0a2d0d0
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/a0a2d0d0

Branch: refs/heads/Jena-1029_subsystem
Commit: a0a2d0d009e2740f042599bc5f228717bd0d62d4
Parents: d60933e
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Sep 18 22:21:22 2015 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Sep 18 22:21:22 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/system/JenaSystem.java   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/a0a2d0d0/jena-core/src/main/java/org/apache/jena/system/JenaSystem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/system/JenaSystem.java b/jena-core/src/main/java/org/apache/jena/system/JenaSystem.java
index 899a344..953e63b 100644
--- a/jena-core/src/main/java/org/apache/jena/system/JenaSystem.java
+++ b/jena-core/src/main/java/org/apache/jena/system/JenaSystem.java
@@ -64,6 +64,22 @@ public class JenaSystem {
      * See {@link #setSubsystemRegistry} to intercept that choice.
      */
     public static void init() {
+        // Any other thread attempting to initialize as well will
+        // first test the volatile outside the lock; if it's 
+        // not INITIALIZED, the thread will attempt to grab the lock
+        // and hence wait, then see initialized as true.
+
+        // But we need to cope with recursive calls of JenaSystem.init() as well.
+        // The same thread will not stop at the lock.
+        // Set initialized to true before a recursive call is possible
+        // handles this.  The recursive call will see initialized true and
+        // and returnn on the first test.
+
+        // Net effect:
+        // After a top level call of JenaSystem.init() returns, tjena has
+        // finishes initialization.
+        // Rececursive calls do not have this property.
+
         if ( initialized )
             return ;
         synchronized(initLock) {
@@ -72,7 +88,7 @@ public class JenaSystem {
                     System.err.println("JenaSystem.init - return");
                 return ;
             } 
-            // Catchs recursive calls, same thread.
+            // Catches recursive calls, same thread.
             initialized = true ;
             if ( DEBUG_INIT )
                 System.err.println("JenaSystem.init - start");


Mime
View raw message