Joining a thread
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).
You may also call join( ) with a timeout argument (in either milliseconds or milliseconds
and nanoseconds) so that if the target thread doesn!ˉt finish in that period of time, the call
join( ) returns anyway.
The call to join( ) may be aborted by calling interrupt( ) on the calling thread, so a try-
catch clause is required.
copied from Thinking in Java
阅读(472) | 评论(0) | 转发(0) |