package thread; /** * 实现Runnable接口 * @author add by jzh 2011-12-17 * */ public class HelloThread implements Runnable { private String name; public HelloThread(String name) { this.name = name; } @Override public void run() { for (int i = 0; i < 5; i++) { System.out.println(name + " = " + i); } } }
package thread; public class HelloTest { public static void main(String args[]) { Thread jzhThread = new Thread(new HelloThread("jzh")); Thread miThread = new Thread(new HelloThread("jiang")); jzhThread.start(); miThread.start(); } }