关于Runnable接口的JDK文档翻译

来源:互联网 发布:未来网络研究院公积金 编辑:程序博客网 时间:2024/05/24 00:53

The Runnable interface should be implemented by any
class whose instances are intended to be executed by a thread.

Runnable 接口应该由那些打算通过某一线程执行其实例的类来实现。其中whose 是定语从句,whose 是定语从句中一个常用的关系代词, 它是关系代词who的所有格,在从句中作定语,也就是说当先行词与从句中某个名词有所属关系,表达“……的”意思时,用关系代词whose 引导定语从句,它既可以指代人,也可以指代物,既可引导限制性定语从句,也可以引导非限制性定语从句。

(注:定语从句修饰一个名词或代词,被修饰的名词,词组或代词即先行词)

 

 

The class must define a method of no arguments called run.

类必须定义一个称为 run 的无参数方法。 call为命名,取名的意思

This interface is designed to provide a common protocol for objects that
wish to execute code while they are active.

设计该接口的目的是为希望在活动时执行代码的对象提供一个公共协议

这里的that是定语从句。

For example,
Runnable is implemented by class Thread.

例如,Thread 类实现了 Runnable
Being active simply means that a thread has been started and has not
yet been stopped.

激活的意思是说某个线程已启动并且尚未停止。

In addition, Runnable provides the means for a class to be
active while not subclassing Thread.

另外,Runnable 为非 Thread 子类的类提供了一种激活方式

A class that implements
Runnable can run without subclassing Thread
by instantiating a Thread instance and passing itself in
as the target. 

通过实例化某个 Thread 实例并将自身作为运行目标,就可以运行实现 Runnable 的类而无需创建 Thread 的子类。

In most cases, the Runnable interface should
be used if you are only planning to override the run()
method and no other Thread methods.
This is important because classes should not be subclassed
unless the programmer intends on modifying or enhancing the fundamental
behavior of the class.