用继承Thread的方法 class A extends Thread{ private int i = 0; @Override public void run() { System.out.println("第一个线程:"); for (int n =1;n=10;n++) { i=i+1; System.out.println(i); } }}class B extends Thread{ private int i =
class A extends Thread{ private int i = 0; @Override public void run() { System.out.println("第一个线程:"); for (int n =1;n<=10;n++) { i=i+1; System.out.println(i); } } } class B extends Thread{ private int i = 0; @Override public void run() { System.out.println("第二个线程:"); for (int n =1;n<=10;n++) { i=i+1; System.out.println(i); } } } class C extends Thread{ private int i = 0; @Override public void run() { System.out.println("第三个线程:"); for (int n =1;n<=10;n++) { i=i-1; System.out.println(i); } } } class D extends Thread{ private int i = 0; @Override public void run() { System.out.println("第四个线程:"); for (int n =1;n<=10;n++) { i=i-1; System.out.println(i); } } } public class manu { public static void main(String[] args) throws Exception { A a = new A(); B b = new B(); C c = new C(); D d = new D(); a.start(); a.join(); b.start(); b.join(); c.start(); c.join(); d.start(); } }