Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Threads (garbage collector and finalizer)

Started by nap202 Oct 19, 2000 at 2:13 PM 0 replies 450+ views
Original Post
nap202
nap202
Hi, can someone explain why the garbage collector thread and finalizer thread aren''t unified in one thread? Is there any reason for the java developers to have chosen this implementation?
felonius
felonius
For one thing I don''t think that this part of the standard - it is something that Java VM implementors may choose for themselves.

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.

Jacob Marner
Jacob Marner, M.Sc.Console Programmer, Deadline Games

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.