1、继承Thread类,新建一个当前类对象,并且运行其start()方法
1 package com.xiaostudy.thread; 2 3 /** 4 * @desc 第一种开启线程的方式 5 * @author xiaostudy 6 * 7 */ 8 public class Demo1_Thread extends Thread { 9 10 public void run() { 11 for (int i = 0; i < 10; i++) { 12 System.out.println(i + " run()..."); 13 } 14 } 15 16 public static void main(String[] args) { 17 Demo1_Thread demo = new Demo1_Thread(); 18 demo.start(); 19 for (int i = 0; i < 10; i++) { 20 System.out.println(i + " main()..."); 21 } 22 } 23 24 }