Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
public class Lazy {
  private static boolean initialized = false;
  static {
    Thread t = new Thread(new Runnable() {
      public void run() {
        initialized = true;
      }
    );
    
    t.start();
    try {
      t.join();
    } catch(InterruptedException ie) {
        throw new AssertionError(ie);
    }
    // Other initialization
  }
  public static void main(String[] args) {
    System.out.println(initialized);
  }
}

...