I have following three classes.
BaseClass.java
public class BaseClass {
static {
load();
}
public static void init() {
System.out.println("base init");
}
private static void load() {
System.out.println("In load method of base class");
DerivedClass dc = new DerivedClass();
System.out.println("Object creation done.");
}
}
DerivedClass.java
public class DerivedClass extends BaseClass {
public DerivedClass() {
System.out.println("derived class constructor");
}
public static boolean isSynthetic(String _attr) {
return true;
}
}
Helper.java
public class Helper {
public static void main(String[] args) {
Thread t = new Thread() {
public void run() {
BaseClass.init();
};
};
t.start();
System.out.println("calling static method of derived class..");
System.out.println(DerivedClass.isSynthetic("test"));
}
}
When I am executing main method from Helper.java, I am getting following output-
calling static method of derived class..
In load method of base class
After this execution is halt but the process is still running. So it seems that there is some deadlock, but I don't understand why is that. Help needed.