"...it takes all the running you can do to keep in the same place. <br />If you want to get somewhere else, you must run at least twice as fast as that!" <br />~ Through the Looking-Glass
Waits for this thread to die.
all events occur in real time
cmbhatt
As you said, if you start a thread before joining, the thread may be dead so there is nothing to join. But I dont see that in your example.
Can we join() main thread from AAA's run()?
all events occur in real time
cmbhatt
1- Main waits for theThread to die before it(main) could proceed. Right?
No, misunderstanding. I meant the code in the run method of AAA is so short, that the AAA thread has already started, run and died, before main reaches the line with the join().2- You mean, the code after theThread.start() is very short so before run could execute main dies.
I do not have an MD in psychiatry, but I guess you are suffering from a desease that is called THREAD (Traumatic Hypermania Related Encephalitis Associated Dissociation)Am I gone mad?
all events occur in real time
One thread may call join() on another thread to wait for
the second thread to complete before proceeding. If a thread
calls t.join() on another thread t,then the calling thread
is suspended until the target thread t finishes (when
t.isAlive() is false.
The correct explanation of the code would be (as I think), main thread (Burkhard, I think I hope you get me what main I am talking about) calls
the join() on the theThread and theThread is alive so main thread joins to the theThread; and Chandra Bhatt is happy with the output.
cmbhatt
cmbhatt
theThread which is not alive at that moment so according to Bruce, main wont join it.
cmbhatt
cmbhatt
cmbhatt
main thread starts as soon as you enter the main() method. So, we need not test whether it's alive or not. We don't say main().start right?
However, if we are joining some other thread, as you said, it will be good to test whether its alive or not.
all events occur in real time
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |