saima kanwal wrote:
What do you mean by implementation detail?? i simply cannot understand your explanation. where has join() come in this code ?? Do you mean to say that the code should run in the manner I expected( should wait forever) but it is due to my particular JVM's behaviour?? or what ?? please explain.
An "implementation detail" is a design decision made during implementation, and not during specification, yielding an effect which is not intended.
In this case, when Sun implemented the join() method they used the Thread object to signal that the thread has terminated. Because of this, any other thread, that waits on the thread object (and not for join()), will have an unintended effect of getting an notification too.
In other words, don't use the thread object for the wait() method. If you do, you will be sharing it with the join() mechanism.
Henry