-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsumer.java
More file actions
29 lines (27 loc) · 735 Bytes
/
Consumer.java
File metadata and controls
29 lines (27 loc) · 735 Bytes
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
/**
* Class that is designed to be run on a thread.
* Each thread removes 50 random numbers from the stack.
*
* @author Kevin Wood
* @version 1.0
*/
public class Consumer implements Runnable {
private SynchronizedBoundedStack randomNumbers;
public Consumer(SynchronizedBoundedStack randomNumbers) {
this.randomNumbers = randomNumbers;
}
/**
* Loops through 50 times popping
* 50 random numbers off of the stack
*/
@Override
public void run() {
for (int i = 0; i < 50; i++) {
try {
randomNumbers.pop();
} catch (InterruptedException e) {
System.out.println("Ran Into An Exception");
}
}
}
}