跟 JDK 学英语 —— Runnable

本文详细解析了Runnable接口在Java中的作用,它为希望在独立线程中执行的类提供了一个通用协议。通过实现Runnable,类可以在不继承Thread的情况下运行,只需创建Thread实例并传递自身作为目标。文章涵盖原文翻译、词汇学习、句子分析和技术要点,帮助后端程序员深入理解多线程编程。
摘要由CSDN通过智能技术生成
一、原文与翻译

@FunctionalInterface
public interface Runnable

The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run.

如果类的实例需要在一个单独的线程中执行,那么这些类应该实现 Runnable 接口。这些类必须定义一个无参的 run 方法。

This interface is designed to provide a common protocol for objects that wish to execute code while they are active. For example, Runnable is implemented by class Thread. Being active simply means that a thread has been started and has not yet been stopped.

本接口是为了给那些在活跃时希望执行代码的对象们提供一个通用的协议而设计的。例如,Thread 类便实现了 Runnable 接口。活跃一般是指一个线程已经启动且还没有停止。

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值