public class TestgarbageCollector extends java.lang.Object
Constructor and Description |
---|
TestgarbageCollector() |
Modifier and Type | Method and Description |
---|---|
void |
testNewInstance()
This method calls the method
createAndReturnInstance() to create an instance, which is not stored
in the class. |
public TestgarbageCollector()
public void testNewInstance()
createAndReturnInstance()
to create an instance, which is not stored
in the class. The reference is known only in a stack variable. The reference is used.
The garbage collector should not attack this instance. To force working of garbage collection,
a Thread.sleep() is built in this method.