Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zhangbaoning;
- /**
- * @Description
- * @Author zhangbaoning
- * @Date 2018/6/22
- */
- public class Test {
- class Thread1 extends Thread {
- @Override
- public void run() {
- System.out.println("继承run方法运行");
- }
- public void start() {
- System.out.println("继承start方法运行");
- }
- }
- class Thread2 implements Runnable {
- @Override
- public void run() {
- System.out.println("实现run方法运行");
- }
- public void start() {
- System.out.println("实现start方法运行");
- }
- }
- public static void main(String[] args) {
- Test test = new Test();
- Thread1 t1 = test.new Thread1();
- t1.start();
- Thread2 t2 = test.new Thread2();
- Thread thread = new Thread(t2);
- thread.start();
- }
- }
Add Comment
Please, Sign In to add comment