質問編集履歴
2
ソースの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -143,3 +143,79 @@
|
|
143
143
|
|
144
144
|
|
145
145
|
```
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
■Mainクラス修正後
|
150
|
+
|
151
|
+
```Java
|
152
|
+
|
153
|
+
public class Main{
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
public static void main(String[] args) throws InterruptedException {
|
158
|
+
|
159
|
+
Stack stack = new Stack();
|
160
|
+
|
161
|
+
Thread1 thread1 = new Thread1(stack);
|
162
|
+
|
163
|
+
Thread2 thread2 = new Thread2(stack);
|
164
|
+
|
165
|
+
thread1.start();
|
166
|
+
|
167
|
+
thread2.start();
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
class Thread1 extends Thread{
|
178
|
+
|
179
|
+
Stack stack = null;
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
public Thread1(Stack stack) {
|
184
|
+
|
185
|
+
this.stack = stack;
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
public void run() {
|
192
|
+
|
193
|
+
stack.push();
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
class Thread2 extends Thread{
|
200
|
+
|
201
|
+
Stack stack = null;
|
202
|
+
|
203
|
+
public Thread2(Stack stack) {
|
204
|
+
|
205
|
+
this.stack = stack;
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
public void run() {
|
212
|
+
|
213
|
+
stack.pop();
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
```
|
1
タイトルの修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【Java】
|
1
|
+
【Java】waitメソッドでスレッドを停止後にnotifyメソッドでスレッドの処理を再開されない
|
test
CHANGED
File without changes
|