Specifications

Sun Services
Java™ Programming Language
Module 13, slide 13 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
The join Method
1 public static void main(String[] args) {
2 Thread t = new Thread(new Runner());
3 t.start();
4 ...
5 // Do stuff in parallel with the other thread for a while
6 ...
7 // Wait here for the other thread to finish
8 try {
9 t.join();
10 } catch (InterruptedException e) {
11 // the other thread came back early
12 }
13 ...
14 // Now continue in this thread
15 ...
16 }