以下代码是声明实现 Runnable 接口的类,以创建新的线程并启动,在横线处填入哪些代码可以实现上述目标( ) ----- 单选
public class MyRunnable implements Runnable {
public void run() {
// do something…
}
}
public class MyRunnableTest {
public static void main(String[] args) {
____________________________________
}
}
A、new MyRunnable().run();
B、new MyRunnable().start();
C、 new Thread(new MyRunnable()).run();
D、new Thread(new MyRunnable()).start(); |
|