以前就读过一点点JDK的源码,今天回顾多线程的时候大致读了读Thread类的源码,感觉源码的精妙无处不在啊。
public void run() {
if (target != null) {
target.run();
}
}
public class Thread implements Runnable {
/* What will be run. */
private Runnable target;
}
public Thread() {
init(null, null, "Thread-" + nextThreadNum(), 0);
}
public Thread(Runnable target) {
init(null, target, "Thread-" + nextThreadNum(), 0);
}
读懂了细节,就觉得越发有味道了!