File size: 547 Bytes
0284885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Thread_implements_package;

public class Thread_demo1 {
    public static void main(String[] args) {
        /*
         *   多线程的第一种启动方式:
         *       1、自己定义一个类继承Thread
         *       2、重写run方法
         *       3、创建子类的对象,并启动线程
         */

        MyThread t1 = new MyThread();
        MyThread t2 = new MyThread();

        t1.setName("线程1");
        t2.setName("线程2");

        //开启线程
        t1.start();
        t2.start();
    }
}