Skip to content

Commit 4bf4c15

Browse files
committed
lecture
1 parent a962e87 commit 4bf4c15

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

src/main/java/io/concurrency/chapter02/exam01/AnonymousRunnableClassExample.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ public class AnonymousRunnableClassExample {
44
public static void main(String[] args) {
55

66
Thread thread = new Thread(new Runnable() {
7+
@Override
78
public void run() {
8-
System.out.println("스레드 실행 중");
9+
System.out.println(Thread.currentThread().getName() + ": 스레드 실행 중..");
910
}
1011
});
12+
1113
thread.start();
14+
1215
}
1316
}

src/main/java/io/concurrency/chapter02/exam01/AnonymousThreadClassExample.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
public class AnonymousThreadClassExample {
44
public static void main(String[] args) {
55

6-
Thread thread = new Thread(){
6+
Thread thread = new Thread() {
7+
@Override
78
public void run() {
8-
System.out.println("스레드 실행 중");
9+
System.out.println(Thread.currentThread().getName() + " :스레드 실행 중..");
910
}
1011
};
1112

Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package io.concurrency.chapter02.exam01;
22

33
public class ExtendThreadExample {
4-
public static void main(String[] args) {
4+
public static void main(String[] args) {
55

6-
MyThread thread1 = new MyThread();
7-
thread1.start();
8-
9-
MyThread thread2 = new MyThread();
10-
thread2.start();
11-
// new MyThread().start();
12-
}
13-
}
14-
class MyThread extends Thread {
15-
public void run() {
16-
System.out.println(Thread.currentThread().getName()+ " :스레드 실행 중");
6+
MyThread myThread = new MyThread();
7+
myThread.start();
178
}
18-
}
9+
}
10+
11+
class MyThread extends Thread{
12+
@Override
13+
public void run() {
14+
System.out.println(Thread.currentThread().getName() + " :스레드 실행 중.. ");
15+
}
16+
}

src/main/java/io/concurrency/chapter02/exam01/ImplementRunnableExample.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ public static void main(String[] args) {
99
}
1010
}
1111

12-
class MyRunnable implements Runnable {
12+
class MyRunnable implements Runnable{
13+
14+
@Override
1315
public void run() {
14-
System.out.println("스레드 실행 중");
16+
System.out.println(Thread.currentThread().getName() + ": 스레드 실행 중");
1517
}
1618
}

src/main/java/io/concurrency/chapter02/exam01/LambdaThreadExample.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
public class LambdaThreadExample {
44
public static void main(String[] args) {
5-
6-
Thread thread = new Thread(() -> System.out.println("스레드 실행 중"));
7-
5+
Thread thread = new Thread(() -> System.out.println(Thread.currentThread().getName() + ": 스레드 실행 중.."));
86
thread.start();
97
}
108
}

0 commit comments

Comments
 (0)