Thread join on itself
Should I get any error ?
I wouldn't expect an error. The javadocs for Thread.join()
do not say that this is an error, and it is just conceivable that some crazy person may use this as another way of doing a sleep
, so an undocumented error would be a bad idea.
I guess that Sun didn't think this was a case that was worth giving special attention to.
The concept of a thread joining itself does not make sense.
It happens out that the join()
method uses the isAlive()
method to
determine when to return from the join()
method. In the current implementation, it also
does not check to see if the thread is joining itself.
In other words, the join()
method returns when and only when the thread is no longer alive. This will have the effect of
waiting forever.