jdk/src/share/classes/sun/misc/VM.java
changeset 21628 50fd58446d64
parent 14342 8435a30053c1
child 22571 985dc9e27435
--- a/jdk/src/share/classes/sun/misc/VM.java	Thu Nov 07 16:55:39 2013 +0100
+++ b/jdk/src/share/classes/sun/misc/VM.java	Fri Nov 08 07:53:57 2013 -0800
@@ -148,6 +148,7 @@
 
 
     private static volatile boolean booted = false;
+    private static final Object lock = new Object();
 
     // Invoked by by System.initializeSystemClass just before returning.
     // Subsystems that are invoked during initialization can check this
@@ -155,13 +156,27 @@
     // application class loader has been set up.
     //
     public static void booted() {
-        booted = true;
+        synchronized (lock) {
+            booted = true;
+            lock.notifyAll();
+        }
     }
 
     public static boolean isBooted() {
         return booted;
     }
 
+    // Waits until VM completes initialization
+    //
+    // This method is invoked by the Finalizer thread
+    public static void awaitBooted() throws InterruptedException {
+        synchronized (lock) {
+            while (!booted) {
+                lock.wait();
+            }
+        }
+    }
+
     // A user-settable upper limit on the maximum amount of allocatable direct
     // buffer memory.  This value may be changed during VM initialization if
     // "java" is launched with "-XX:MaxDirectMemorySize=<size>".