您的位置:首页 > 其它

5.6 实现Runable接口定义线程和直接继承Thead类定义线程的区别

2011-01-29 11:10 309 查看
p { margin-bottom: 0.21cm; }
用继承Thread
类实现线程
即调用线程时 调用参数为空的构造方法
start
();方法多少次都只启动了一个线程


TestThead
tethead =

new

TestThead();

//
testThead.setDaemon(true);

tethead.start();

tethead.start();

tethead.start();

用实现
Runable

接口的方式调用线程
调用一次
start()

就启动一次线程

TestThead
tethead =

new

TestThead();

new

Thread(tethead).start();

new

Thread(tethead).start();

new

Thread(tethead).start();

new

Thread(tethead).start();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐