由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - implements runable 和 extends thread
相关主题
ZT: 关于性爱的多线程问题研究(一)想听本版对下面这段话的点评
问个Thread 的问题,java certificate里的can applet implements runnable?
能这么 create thread 吗?Re: How to showStatus in Applet?
线程问题。FrameWork of Thread application 1
好虫,exploit等大牛请进--关于htmlunitRe: connection pool
●●●●紧急求助JAVA初级问题,今天project due●●●●Can Java thread return a value?
关于inner class的继承几个问题
一道java题一个基本问题。
相关话题的讨论汇总
话题: thread话题: implements话题: runable话题: extends话题: runnable
进入Java版参与讨论
1 (共1页)
p***p
发帖数: 559
1
到底有什么区别
xt
发帖数: 17532
2

extends Thread可以直接用那个class做Thread class来对待.
implements Runnable在create thread的时候必须用new Thread()
来产生一个Thread.但是Runnable有个好处,就是java 不支持multi-
inheritance.所以如果你的class有super class,就不能再extend
Thread但是可以implements Runnable.

【在 p***p 的大作中提到】
: 到底有什么区别
m******t
发帖数: 2416
3

I'd always implement Runnable. It provides greater flexibility and less
coupling with the threading api at the mere price of one extra line of code.

【在 p***p 的大作中提到】
: 到底有什么区别
p***p
发帖数: 559
4
言简意赅呀。另外我发现高手编程序就是用
final static多的。

【在 xt 的大作中提到】
:
: extends Thread可以直接用那个class做Thread class来对待.
: implements Runnable在create thread的时候必须用new Thread()
: 来产生一个Thread.但是Runnable有个好处,就是java 不支持multi-
: inheritance.所以如果你的class有super class,就不能再extend
: Thread但是可以implements Runnable.

xt
发帖数: 17532
5

This is usually for optimisation purposes, and therefore for
better performance.

【在 p***p 的大作中提到】
: 言简意赅呀。另外我发现高手编程序就是用
: final static多的。

1 (共1页)
进入Java版参与讨论
相关主题
一个基本问题。好虫,exploit等大牛请进--关于htmlunit
java的接口runnable●●●●紧急求助JAVA初级问题,今天project due●●●●
另一个入门问题。关于inner class的继承
请问关于用threadPoolExecutor实现threadpool的问题?一道java题
ZT: 关于性爱的多线程问题研究(一)想听本版对下面这段话的点评
问个Thread 的问题,java certificate里的can applet implements runnable?
能这么 create thread 吗?Re: How to showStatus in Applet?
线程问题。FrameWork of Thread application 1
相关话题的讨论汇总
话题: thread话题: implements话题: runable话题: extends话题: runnable