Thread本身是一个类,其run():
正常情况下, target(即传入的new Runnable()对象)不为空,就是执行target里面的run方法
但是,重新run()方法之后,就不会在执行target.run(),除非显示调用: super.run()
@Override public void run() { if (target != null) { target.run(); } }
public class StringTest { private static int a; private static int b; public static void main(String[] args) { a = 1; b = 1; new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { } while (a < 5) { System.out.println("a=" + a); a++; b--; } } }) { public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { } while (b < 5) { System.out.println("b=" + b); b++; a--; } }; }.start(); } }