创建并使用线程

时间:2020-12-30 18:40:26
【文件属性】:
文件名称:创建并使用线程
文件大小:26KB
文件格式:PDF
更新时间:2020-12-30 18:40:26
线程 创建并使用线程   两种方式,创建新的线程:   实现 Runnable 接口,Runnable 接口定义了一个方法:run。run 方法中的代码,将在创建的线程中执行。实现了 Runnable 接口的对象,作为 Thread 构造方法的参数。   public class HelloRunnable implements Runnable {   public void run() {   System.out.println(Hello from a thread!);   }   public static void main(St

网友评论