Browse Source

자바 스레드 교안

tobby48 3 years ago
parent
commit
fd1d0b7a52

+ 1
- 1
src/kr/co/swh/lecture/java/scene4/ThreadHigh1Main.java View File

33
 				// TODO Auto-generated catch block
33
 				// TODO Auto-generated catch block
34
 				e.printStackTrace();
34
 				e.printStackTrace();
35
 			}
35
 			}
36
-			System.out.println("5의 배수일때까지 합산은 : " + threadA.getSum());
36
+			System.out.println("5까지 합산은 : " + threadA.getSum());
37
 		}
37
 		}
38
 	}
38
 	}
39
 }
39
 }

+ 4
- 0
src/kr/co/swh/lecture/java/scene4/ThreadHigh3Main.java View File

29
 	public synchronized void methodA() {
29
 	public synchronized void methodA() {
30
 		System.out.println("ThreadA의 methodA() 작업 실행");
30
 		System.out.println("ThreadA의 methodA() 작업 실행");
31
 		notify(); 	//일시정지 상태에 있는 ThreadB를 실행대기 상태로 만듬.
31
 		notify(); 	//일시정지 상태에 있는 ThreadB를 실행대기 상태로 만듬.
32
+		System.out.println("ThreadA의 methodA() notify 이후");
32
 		try {
33
 		try {
33
 			wait();	//ThreadA를 일시정지 상태로 만듬.
34
 			wait();	//ThreadA를 일시정지 상태로 만듬.
35
+			System.out.println("ThreadA의 methodA() wait 이후");
34
 		} catch (Exception e) {
36
 		} catch (Exception e) {
35
 		}
37
 		}
36
 	}
38
 	}
38
 	public synchronized void methodB() {
40
 	public synchronized void methodB() {
39
 		System.out.println("ThreadB의 methodB() 작업 실행");
41
 		System.out.println("ThreadB의 methodB() 작업 실행");
40
 		notify();	//일시정지 상태에 있는 ThreadA를 실행대기 상태로 만듬.
42
 		notify();	//일시정지 상태에 있는 ThreadA를 실행대기 상태로 만듬.
43
+		System.out.println("ThreadA의 methodB() notify 이후");
41
 		try {
44
 		try {
42
 			wait();	//ThreadB를 일시정지 상태로 만듬.
45
 			wait();	//ThreadB를 일시정지 상태로 만듬.
46
+			System.out.println("ThreadA의 methodB() wait 이후");
43
 		} catch (Exception e) {
47
 		} catch (Exception e) {
44
 		}
48
 		}
45
 	}
49
 	}