开发者

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 ;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜