Ver código fonte

자바 스레드 교안

tobby48 3 anos atrás
pai
commit
fd1d0b7a52

+ 1
- 1
src/kr/co/swh/lecture/java/scene4/ThreadHigh1Main.java Ver arquivo

@@ -33,7 +33,7 @@ public class ThreadHigh1Main {
33 33
 				// TODO Auto-generated catch block
34 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 Ver arquivo

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