1) is the Static Objects eligible for the eligibilization of GC.
There is not such thing as static objects, just static references to objects. Both static variables and instance variables could reference the same object. When such object is unreachable by any means, it will be elegible for gc, just as any other object.
About finalization here's an example:
Just make sure to call super.finalize(). Because the finalize method is not like the constructor, wich call parent constructors automatically.
3)THe thread for which the run method completes or it exits the program is considered as the Dead Thread.
I thinks that's right!
All the other thread are considered live thread i.e other states like block,wait...
I think that's not true. A thread is alive only after its start method have been called and befored its run method has completed.
4)The GC will run when needed irrespective whether the user invokes it or not?
Not absolutlely true, you could run a program and gc could never run, simple because the conditions to be run were never met. However if it has to run you can do nothing to help it. [ April 26, 2005: Message edited by: Edwin Dalorzo ]
you can overload the finalize method, but still the original one will be called. so, for whatever reason you would like to do this for, you would at least need to overide the finalize method in order to manually call your overloaded one.
Originally posted by Tony Morris: After start() has been called, the thread enters the "ready to run" state. The thread may enter the "running" state at the discretion of the thread scheduler which is completely indeterminate.
Yes, a thread in a blocked/waiting/sleeping state is alive, according to K&B p. 507.
The 5 states of a thread: New: before start() is called. not alive Runnable: after start() is called, and also after returning from a blocked/waiting/sleeping state. alive Running: thread scheduler has selected this thread to run from the runnable pool and the thread is currently executing its run method. alive Waiting/blocked/sleeping: thread is alive but is not currently eligible to run, although it may return to being runnable later. It's either blocked trying to get in a synchronized block or waiting for a resource, or it's sleeping because the code told it to sleep, or it's waiting because the code told it wait for notification. alive Dead: run method has completed. Thread object still exists, but the thread of execution can not be started again. not alive
SCJA 1.0 (98%), SCJP 1.4 (98%)
Joined: Apr 25, 2005
Thanks for posting the content Joe. That would explain everything clearly.