You can direct a program to wait for a thread to finish its workthat is,
for the run
method to returnusing the join
method, as
shown in the following example, in which the thread is the value of the
thread
variable:
thread.join(0);
The argument specifies a time interval in milliseconds that your program is to wait. A time interval of zero indicates that you want your program to wait until the thread finishes its work, no matter how long the wait.