Skip to content

Commit 4acfe00

Browse files
committed
Add Thread Demo
1 parent dac6a10 commit 4acfe00

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/ThreadDemo/MyRunnable.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ThreadDemo;
2+
3+
/**
4+
* @author:Gerry
5+
* @description:
6+
* @date: Created in 2018/12/20
7+
*/
8+
public class MyRunnable implements Runnable {
9+
@Override
10+
public void run()
11+
{
12+
System.out.println("MyRunnable");
13+
}
14+
}

src/ThreadDemo/MyThread.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ThreadDemo;
2+
3+
/**
4+
* @author:Gerry
5+
* @description:
6+
* @date: Created in 2018/12/20
7+
*/
8+
public class MyThread extends Thread {
9+
@Override
10+
public void run()
11+
{
12+
super.run();
13+
System.out.println("MyThread");
14+
}
15+
}

src/ThreadDemo/Run.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package ThreadDemo;
2+
3+
/**
4+
* @author:Gerry
5+
* @description:
6+
* @date: Created in 2018/12/20
7+
*/
8+
public class Run {
9+
public static void main(String[] args) {
10+
MyThread myThread=new MyThread();
11+
myThread.start();
12+
System.out.println("MyThread运行结束!");
13+
14+
MyRunnable runnable = new MyRunnable();
15+
Thread thread = new Thread(runnable);
16+
thread.start();
17+
System.out.println("MyRunnable运行结束");
18+
}
19+
}

0 commit comments

Comments
 (0)