Hi All,
I found very interesting thing while trying with
java . Please find the code below:
public class SimpleTest {
static{
System.out.println(Thread.currentThread().getName());
System.exit(0);
}
}
The above program runs without any exception(Well & goodsince im exiting in the static block itself) . But i got the following as the output:
main
Since i haven't started the main
thread, how does it got created. As per my understanding static block is executed during the load time. Then how does main thread come into picture?
Can anyone please give the brief introduction how the compilation,loading and execution done in jvm ? Also the use of rt.jar?
Thanks in advance,
Brinal