-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoConcurrency.java
37 lines (32 loc) · 943 Bytes
/
DemoConcurrency.java
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
30
31
32
33
34
35
36
37
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
/**
* PS Software Engineering WS2015 <br>
* <br>
*
* Demo-Class to demonstrate functionality of Poducer - Buffer - Consumer
*
* @author Kevin Schoergnhofer, Markus Seiwald
*
*/
public class DemoConcurrency {
public static void main(String[] args){
Buffer buffer = new Buffer(10);
BufferedReader input = null;
String inputfilename = "Input.txt";
try {
FileInputStream fstream = new FileInputStream(inputfilename);
input = new BufferedReader(new InputStreamReader(fstream));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Thread prod = new Thread(new Producer(buffer, input));
Thread con1 = new Thread(new Consumer(buffer, System.out));
Thread con2 = new Thread(new Consumer(buffer, System.err));
prod.start();
con1.start();
con2.start();
}
}