-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter58.java
48 lines (42 loc) · 1.25 KB
/
Chapter58.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package chapter58;
import javax.swing.JOptionPane;
class Three extends Thread{
@Override
public void run() {
for(int i = 10;i>0;i--) {
System.out.println(i);
try {
Thread.sleep(1000);//1초 = 1/1000
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public class ThreadEx4 {
public static void main(String[] args) {
/*
//싱글 스레드
String in = JOptionPane.showInputDialog("값을 입력하세요");
System.out.println(in);
for(int i = 10;i>0;i--) {
System.out.println(i);
try {
Thread.sleep(1000);//1초 = 1/1000
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("Main Thread 종료!!!");
*/
//멀티스레드
//Main 스레드와 Three 스레드 동시에 작업
Three th1 = new Three();
th1.start();
String in = JOptionPane.showInputDialog("값을 입력하세요");
System.out.println(in);
System.out.println("Main Thread 종료!!!");
}
}