Java initialize question
What does the below code do whe开发者_高级运维n you instantiate the StudentRegistrar class?
public class StudentRegistrar
{
public StudentRegistrar ();
{
new RecordManager().Initialize();
}
}
It doesn't necessary destroy the RecordManager
immediately. Initialize()
may spawn a new thread which can then hold a reference to the RecordManager
. Since new threads are a garbage collection root, the RecordManager
reference will be reachable from that root and therefore it will not be cleaned up.
It really depends on what Initialize
does!
It creates an instance of RecordManager
, calls the Initialize()
method and then destroys the instance of RecordManager
.
EDIT: Actually it won't compile due to the spurious ;
精彩评论