blob: 0644f1c434aad8693c482d0db37fbbf2f94ed6d7 [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001// Copyright 2007 The Android Open Source Project
2
3/**
4 * Make sure that a sub-thread can join the main thread.
5 */
6public class Main {
7 public static void main(String[] args) {
8 Thread t;
9
10 t = new Thread(new JoinMainSub(Thread.currentThread()), "Joiner");
11 System.out.print("Starting thread '" + t.getName() + "'\n");
12 t.start();
13
14 try { Thread.sleep(1000); }
15 catch (InterruptedException ie) {}
16
17 System.out.print("JoinMain starter returning\n");
18 }
19}
20
21class JoinMainSub implements Runnable {
22 private Thread mJoinMe;
23
24 public JoinMainSub(Thread joinMe) {
25 mJoinMe = joinMe;
26 }
27
28 public void run() {
29 System.out.print("@ JoinMainSub running\n");
30
31 try {
32 mJoinMe.join();
33 System.out.print("@ JoinMainSub successfully joined main\n");
34 } catch (InterruptedException ie) {
35 System.out.print("@ JoinMainSub interrupted!\n");
36 }
37 finally {
38 System.out.print("@ JoinMainSub bailing\n");
39 }
40 }
41}