- public synchronized void start() {
- /**
- * This method is not invoked for the main method thread or "system"
- * group threads created/set up by the VM. Any new functionality added
- * to this method in the future may have to also be added to the VM.
- *
- * A zero status value corresponds to state "NEW".
- */
- if (threadStatus != 0)
- throw new IllegalThreadStateException();
- group.add(this);
- start0();
- if (stopBeforeStart) {
- stop0(throwableFromStop);
- }
- }
- private native void start0();
复制代码 上面是start()的源码 可以看到它调用了一个本地方法private native void start0();
native是方法修饰符。Native方法是由另外一种语言(如c/c++,FORTRAN,汇编)实现的本地方法。
因为在外部实现了方法,所以在java代码中,就不需要声明了,有点类似于接口。 |