Reputation: 1495
In following code snippet, will published
object be garbage collected ? Is there any chance that published
will stay around as a half constructed object ?
final class Publisher
{
public static volatile Publisher published;
public Publisher()
{
published = this;
throw new RuntimeException("Construction not allowed.");
}
}
Upvotes: 0
Views: 164