一个简单的java线程代码。 其实线程也就那么回事, package thead; public class testThead2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub thead1 t1 = new thead1(); thead2 t2 = new thead2(); new Thread(t1).start(); new Thread(t2).start(); } } class thead1 implements Runnable { thead1() { } public void run() { // TODO Auto-generated method stub for (int i = 0; i < 50; i++) { if (i % 2 == 0) System.out.println("hello, i am the first thead " + i); } } } class thead2 implements Runnable { thead2() { } public void run() { // TODO Auto-generated method stub for (int i = 0; i < 50; i++) { if (i % 2 == 1) System.out.println("hi , i am the second thead " + i); } } }