不废话,就一个类,直接拷贝代码执行
1 package com.jtfr.demo;
2
3 /**
4 * 主要:继承 Thread 类和 Runnable接口
5 * @author 陈康明 qq:1123181523
6 * @date 2018年12月27日
7 */
8 public class TestBaseDemo {
9
10 public static void main(String[] args) {
11 new MyThread().start();
12 new Thread(new MyRunnable()).start();
13 }
14 }
15
16 /**
17 * 继承 Thread 类
18 */
19 class MyThread extends Thread{
20 @Override
21 public void run() {
22 System.out.println("继承的 Thread 类");
23 }
24 }
25 /**
26 * 实现的 Runnable 接口
27 */
28 class MyRunnable implements Runnable{
29
30 @Override
31 public void run() {
32 System.out.println("实现的 Runnable 接口");
33 }
34
35 }