一、继承java.lang.Thread(继承Thread而重写run()方法) 例子: public class Hello extends Thread{ int i; public void run(){ while(true){ System.out.println("Hello "+i++); if(i==10) break; } } } public class HelloThread { public static void main(String[] args){ Hello h1 = new Hello(); Hello h2 = new Hello(); h1.start(); h2.start(); } } 第二、实现Runnable接口(实现Runnable接口) 例子: public class TestThread { public static void main(String args[]) { Xyz r = new Xyz(); Xyz r1 = new Xyz(); Thread t1 = new Thread(r); Thread t2 = new Thread(r1); t1.start(); t2.start(); } } class Xyz implements Runnable { int i; public void run() { i = 0; while (true) { System.out.println("Hello " + i++); if ( i == 50 ) { break; } } } }