hi i have some doubts on
thread topics... mentioned below ... kindly clear them..
1. in K&B there its wrriten
There�s nothing special about the run()method as far as Java is concerned. Like
main(), it just happens to be the name (and signature) of the method that
the new thread knows to invoke. So if you see code that calls the run()method
on a Runnable (or even on a Thread instance), that�s perfectly legal. But it
doesn�t mean the run()method will run in a separate thread! Calling a run()
method directly just means you�re invoking a method from whatever thread is
currently executing, and the run()method goes onto the current call stack
rather than at the beginning of a new call stack. The following code does not
start a new thread of execution: is that means that run() can be called as any other method and new stack will only be created by clainng obj.start() method.... ?
===================================
2. in K&B ... on page 505 there written..
When a thread completes its run() method, the thread ceases to be a thread of
execution. The stack for that thread dissolves, and the thread is considered dead. Not
dead and gone, however, just dead. It�s still a Thread object, just not a thread of execution.
So if you�ve got a reference to a Thread instance, then even when that Thread instance
is no longer a thread of execution, you can still call methods on the Thread instance,
just like any other Java object. What you can�t do, though, is call start() again.
Once a thread is dead, it can never be restarted! got confused......in later there written when thread is dead we can't use it and we can't use its methods but here above written that we still can call method on thread instance ?
remove my confusion ...!!!
========================================