Thread中的run()

      /* What will be run. */
      private Runnable target;
如果线程在创建时传入了Runnable运行对象,那么该对象的run方法将被调用
1
/** 2 * If this thread was constructed using a separate 3 * <code>Runnable</code> run object, then that 4 * <code>Runnable</code> object's <code>run</code> method is called;
否则,不做任何事且返回
5 * otherwise, this method does nothing and returns. 6 * <p>
    Thread的子类应该重写这个方法
7 * Subclasses of <code>Thread</code> should override this method. 8 * 9 * @see #start() 10 * @see #stop() 11 * @see #Thread(ThreadGroup, Runnable, String) 12 */ 13 @Override 14 public void run() { 15 if (target != null) { 16 target.run(); 17 } 18 }

猜你喜欢

转载自www.cnblogs.com/xiaofan156/p/11774365.html