已采纳回答 / hyrlh
因为创建线程只有两种方法:其一是实例化Thread类或者子类,其二是实现Runnable接口;为什么要实例化两次呢?因为实现Runnable接口之后,还要调用包含“实现Runnable接口”的Thread类的构造方法,才会创建一个线程;
2016-10-28
最新回答 / 慕神1905738
package com.imooc.concurrent;public class Actor extends Thread { public void run() { System.out.println(getName() + "is an actor"); int count = 0; boolean a=true; while (a){ System.out.println(getName() + "show begins" + (++count)); if (count==...
2016-10-25
已采纳回答 / 我一定要去看最蓝的天空
Thread类实际上无法达到资源共享的目的。Runnable适合于多个相同程序代码线程去处理统一资源的情况,把虚拟的cpu(线程)同程序的代码,数据有效分离,较好体现面向对象的编程的思想.其实在这里军队用runable和thread关系都不大,因为军队是各自的厮杀,没有共享的资源。<...code...><...code...>运行一下,通过对比希望可以帮助你理解~
2016-10-22