Is Java class initialized by the thread which use it for the first time?
Posted
by oo_olo_oo
on Stack Overflow
See other posts from Stack Overflow
or by oo_olo_oo
Published on 2010-03-18T13:04:25Z
Indexed on
2010/03/18
13:11 UTC
Read the original article
Hit count: 120
Lets assume following classes definition:
public class A {
public final static String SOME_VALUE;
static {
SOME_VALUE = "some.value";
}
}
public class B {
private final String value = A.SOME_VALUE;
}
Assuming that the class A hasn't been loaded yet, what does happen when object of the class B is instantiated by some thread T? The class A has to be loaded and instantiated first. But my question is: if it's done in context of the thread T, or rather in context of some other (special) "classloader" thread?
© Stack Overflow or respective owner