Professional Documents
Culture Documents
private DeadlockQuiz(){
super();
launchThread();
}
while(t.isAlive()){
try{
wait(100);
}catch (InterruptedException e) {
// TODO: handle exception
}
}
}
}
In Java code, a class or interface variable for its first active use must be
initialized, the process of setting class variables to their proper initial
values.
All the class variable initializers and static initializers of a type are collected by
the Java compiler and placed into one special method. For classes, this method
is called the class initialization method; for interfaces, the interface initialization
method. In Java class files for both classes and interfaces, this method is named
" clinit()". Regular methods of a Java application cannot invoke a method. This
kind of method can only be invoked by the Java virtual machine, which invokes it
to set a type's static variables to their proper initial values.
The code of the clinit() method does not explicitly invoke a superclass's clinit()
method. Before a Java virtual machine invokes the clinit() method of a class,
therefore, it must make certain the clinit() methods of superclasses have been
executed.
Note: Not all classes will necessarily have a clinit() method in their class
file. If a class declares no class variables or static initializers, it won't have
a clinit() method.
If a class declares class variables, but doesn't explicitly initialize them with
class variable initializers or static initializers, it won't invoke the clinit ()
method. If a class contains only class variable initializers for static final variables,
and those class variable initializers use compile-time constant expressions, that
class won't invoke the clinit () method. Only those classes that actually require
Java code to be executed to initialize class variables to proper initial values will
invoke the class initialization method.
Java virtual machines must also make sure the initialization process is properly
synchronized. If multiple threads need to initialize a class, only one thread should
be allowed to perform the initialization while the other threads wait. After the
active thread completes the initialization process, it must notify any waiting
threads.