How can one get the name of the class from a static method in that class. For example public class MyClass { public static String getClassName() { String name = ????; // what goes here so …
Tag: static
Thread safety of static blocks in Java
Let’s say I have some Java code: If a thread is initializing SomeClass’s Class object and is in the middle of initializing the values in the static block when a second thread wants to load SomeClass’s Class again, what happens to the static block? Does the second thread ignore it assuming it’s already initialized even though the first thread is