Thread
构造器
我们以喜闻乐见的为例:
1public Thread(Runnable target) {
2 init(null, target, "Thread-" + nextThreadNum(), 0);
3}
第一个参数为线程组,最后一个为栈大小。init方法就是一些内部属性的赋值操作。
启动
1public synchronized void start() {
2 if (threadStatus != 0)
3 throw new IllegalThreadStateException();
4 boolean started = false;
5 start0();
6 started = true;
7}
核心 便在于native方法start0.