public static void main(String[] args) {
    Service service = new Service();

    ThreadA a = new ThreadA(service);
    a.setName("A");
    a.start();
    ThreadB b = new ThreadB(service);
    b.setName("B");
    b.start();
    ThreadC c = new ThreadC(service);
    c.setName("C");
    c.start();
  }
Exemple #2
0
  @Override
  public void run() {
    try {
      ThreadA a = new ThreadA();
      a.start();
      a.join();

      System.out.println("线程B在run end处打印了");
    } catch (InterruptedException e) {
      System.out.println("线程B在catch处打印了");
      e.printStackTrace();
    }
  }