Home Segments Top Top Previous Next

900: Sidetrip

You can direct a program to wait for a thread to finish its work—that is, for the run method to return—using 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.