Which method you define as the starting point of new thread in a class from which n thread can be execution?
下列哪一个方法你认为是新线程开始执行的点,也就是从该点开始线程n被执行。
public void start();
public void run();
public static void main(String args[]);
public void runnable();
答案: public void run();
为什么不是start呢?
题目的意思是,下列哪一个方法你认为是新线程开始执行的点,也就是从该点开始线程n被执行。
了解过线程的知识我们知道:
start()方法是启动一个线程,此时的线程处于就绪状态,但并不一定就会执行,还需要等待CPU的调度。
run()方法才是线程获得CPU时间,开始执行的点。所以你明白了嘛