方式一:实现runnable接口 public class testStatic implements Runnable { int outer = 0 ; public void run(){ System.out.print("da"); } } 测试 public static void main(String[] args){ testStatic s = new testStatic(); Thread f = new Thread(s,"thead1"); f.start(); System.out.println(f.getName()); } 方式二:继承thread类 class testThread extends Thread { testThread(String name){ super(name); } public void run(){ System.out.print("ad"); } } 测试 public static void main(String[] args){ testThread tt = new testThread("thread2"); tt.run(); System.out.println(tt.getName()); }