We cant say surly when its work.We know that garbage collector uses a mark and sweep algorithm, When we are seeing about the java implementation its true but in the case of java specification we cant sure abut the java implementation.
We also know that garbage collector uses reference counting;The important concept is which we must to know that when does an object become eligible for garbage collection.Its ans is the thread.We cans say that every Java program has from one to many threads,Each thread has its own little execution stack. The garbage collector does some magical, unknown operations, and when it discovers an object that can\'t be reached by any live thread it will consider that object as eligible for deletion, and it might even delete it at some point.When we are discussing about reaching an object, we\'re really talking about having a reachable reference variable that refers to the object in question. If our Java program has a reference variable that refers to an object ,and that reference variable is available to a live thread, then that object is considered reachable.
By:umang
Date:2014-03-09 00:00:00
Overriding hashCode() and equals()
What It Means if we Don\'t Override equals()
Implementing an equals() Method
So What Do we Do with a Collection?
Key Interfaces and Classes of the Collections Framework
Overview of Memory Management and Garbage Collection
Overview of Java\'s Garbage Collector
When Does the Garbage Collector Run?
How Does the Garbage Collector Work?
Reassigning a Reference Variable