p***p 发帖数: 559 | |
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多的。
|