質問編集履歴
2
ソースの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -70,4 +70,42 @@
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
|
73
|
+
```
|
74
|
+
|
75
|
+
■Mainクラス修正後
|
76
|
+
```Java
|
77
|
+
public class Main{
|
78
|
+
|
79
|
+
public static void main(String[] args) throws InterruptedException {
|
80
|
+
Stack stack = new Stack();
|
81
|
+
Thread1 thread1 = new Thread1(stack);
|
82
|
+
Thread2 thread2 = new Thread2(stack);
|
83
|
+
thread1.start();
|
84
|
+
thread2.start();
|
85
|
+
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
class Thread1 extends Thread{
|
90
|
+
Stack stack = null;
|
91
|
+
|
92
|
+
public Thread1(Stack stack) {
|
93
|
+
this.stack = stack;
|
94
|
+
}
|
95
|
+
|
96
|
+
public void run() {
|
97
|
+
stack.push();
|
98
|
+
}
|
99
|
+
}
|
100
|
+
class Thread2 extends Thread{
|
101
|
+
Stack stack = null;
|
102
|
+
public Thread2(Stack stack) {
|
103
|
+
this.stack = stack;
|
104
|
+
}
|
105
|
+
|
106
|
+
public void run() {
|
107
|
+
stack.pop();
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
73
111
|
```
|
1
タイトルの修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
【Java】
|
1
|
+
【Java】waitメソッドでスレッドを停止後にnotifyメソッドでスレッドの処理を再開されない
|
body
CHANGED
File without changes
|