1. 首页
  2. 数据库
  3. 其它
  4. 创建并使用线程

创建并使用线程

上传者: 2021-01-16 17:36:35上传 PDF文件 26KB 热度 19次
创建并使用线程 两种方式,创建新的线程: 实现 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
下载地址
用户评论