123456789101112131415161718192021222324252627282930313233 |
- public class TestJoin {
- public static void main(String[] args) {
- TestJoinA a = new TestJoinA();
- TestJoinB b = new TestJoinB(a);
- b.start();
- a.start();
- }
- }
- class TestJoinA extends Thread {
- @Override
- public void run() {
- System.out.println("A");
- }
- }
- class TestJoinB extends Thread {
- private TestJoinA a;
- public TestJoinB(TestJoinA a) {
- this.a = a;
- }
- @Override
- public void run() {
- try {
- a.join();
- } catch (Exception e) {
- e.printStackTrace();
- }
- System.out.println("B");
- }
- }
|