Skip to content

Commit 9c476bd

Browse files
committed
lecture
1 parent 95c9423 commit 9c476bd

6 files changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.concurrency.chapter02.exam01;
2+
3+
public class AnonymousRunnableClassExample {
4+
public static void main(String[] args) {
5+
6+
Thread thread = new Thread(new Runnable() {
7+
public void run() {
8+
System.out.println("무명 Runnable 클래스에 의한 스레드 실행 중");
9+
}
10+
});
11+
thread.start();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.concurrency.chapter02.exam01;
2+
3+
public class AnonymousThreadClassExample {
4+
public static void main(String[] args) {
5+
6+
Thread thread = new Thread(){
7+
public void run() {
8+
System.out.println("무명 Thread 클래스에 의한 스레드 실행 중");
9+
}
10+
};
11+
12+
thread.start();
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.concurrency.chapter02.exam01;
2+
3+
public class ExtendThreadExample {
4+
public static void main(String[] args) {
5+
6+
MyThread thread = new MyThread();
7+
thread.start();
8+
9+
// new MyThread().start();
10+
}
11+
}
12+
class MyThread extends Thread {
13+
public void run() {
14+
System.out.println("스레드 확장에 의한 실행 중");
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.concurrency.chapter02.exam01;
2+
3+
public class ImplementRunnableExample {
4+
public static void main(String[] args) {
5+
6+
MyRunnable task = new MyRunnable();
7+
Thread thread = new Thread(task);
8+
thread.start();
9+
}
10+
}
11+
12+
class MyRunnable implements Runnable {
13+
public void run() {
14+
System.out.println("Runnable 구현에 의한 스레드 실행 중");
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.concurrency.chapter02.exam01;
2+
3+
public class LambdaThreadExample {
4+
public static void main(String[] args) {
5+
6+
Thread thread = new Thread(() -> System.out.println("람다 표현식에 의한 스레드 실행 중"));
7+
8+
thread.start();
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.concurrency.chapter02.exam02;
2+
3+
public class ThreadStartRunExample {
4+
public static void main(String[] args) {
5+
6+
MyRunnable task = new MyRunnable();
7+
Thread thread = new Thread(task);
8+
thread.start();
9+
// thread.run();
10+
// task.run();
11+
}
12+
}
13+
14+
class MyRunnable implements Runnable {
15+
public void run() {
16+
System.out.println("스레드 실행 중");
17+
}
18+
}

0 commit comments

Comments
 (0)