Skip to content

Instantly share code, notes, and snippets.

@cgrand
Created May 28, 2019 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrand/7e4efd65d3954092e31e329b0a70e35d to your computer and use it in GitHub Desktop.
Save cgrand/7e4efd65d3954092e31e329b0a70e35d to your computer and use it in GitHub Desktop.
package doubetrouble;
import java.util.concurrent.Callable;
public class Main implements Callable<Object> {
private static class Constants {
final static Object constant;
static {
System.err.println("Lazy cosntants init");
constant = new Object();
}
}
static {
System.err.println("Main init");
}
public static void main(String[] args) {
try {
new Main().call();
} catch (Exception e) {
e.printStackTrace();
}
}
public Object call() throws Exception {
System.err.println("Main call");
return Constants.constant;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment