@FunctionalInterface public interface Runnable
Runnable接口应该被任何类的实例的目的是通过一个线程执行的实施。类必须定义一个称为
run
此接口旨在为那些希望在它们活动时执行代码的对象提供一个通用的协议。例如,Runnable通过类Thread实施。激活的意思是说一个线程已启动并且尚未停止。
此外,Runnable一类是主动的而不是子类Thread提供手段。一个类实现Runnable可以运行没有子Thread实例化一个Thread实例并将自身作为目标。在大多数情况下,这Runnable接口应该是如果你只打算重写run()方法并没有其他Thread方法。这是重要的因为方法重写,继承类不应该继承除非程序员打算修改或增强类的基本行为。
void run()
Runnable是用来创建一个线程,启动线程使对象的
run方法在单独执行的线程调用。
该方法run总承包是无论采取任何行动。
Thread.run()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.