When reading the JDK source code, we found a Class named Void, which is a non-instantiated placeholder Class that holds a reference to the Class object that identifies the Java keyword Void.
The Void class is defined as follows:
Package java. lang;
Public final class Void {
Private Void (){
}
Public static final Class TYPE = Class. getPrimitiveClass ("void ");
}
I found the source code of the ThreadGroup class. The source code is as follows:
Public ThreadGroup (ThreadGroup threadgroup, String s ){
This (checkParentAccess (threadgroup), threadgroup, s); // The checkParentAccess () method does not return a value. this will call the following construction with parameters.
}
Private ThreadGroup (Void void1, ThreadGroup threadgroup, String s ){
NUnstartedThreads = 0;
Name = s;
MaxPriority = threadgroup. maxPriority;
Daemon = threadgroup. daemon;
VmAllowSuspension = threadgroup. vmAllowSuspension;
Parent = threadgroup;
Threadgroup. add (this );
}
In addition to the above usage, I still don't know what other special usage of the Void class is. Write down it first.