[java] Threads (garbage collector and finalizer),
Members - Reputation: 122
Posted 19 October 2000 - 08:30 PM
And why? Because of concurrency. Garbage collection and finalization is something that often can be done in parallel and by making two threads you can utilize multi processor systems much better.
The garbage collector on most VMs in a mark-sweep algorithm that starts with the application object and tries to reach all other objects. Those not reachable are marked for finalization, for instance by putting them in a queue.
The finalization thread can handle this queue and call finalize routines while the other thread performs the mark-sweep algorithm.