-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperature.java
More file actions
58 lines (47 loc) · 1.47 KB
/
Temperature.java
File metadata and controls
58 lines (47 loc) · 1.47 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Random;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
public class Temperature extends Consumer {
String result = Readfile("src/temperature.txt");
String value[] = result.split("\n");
Thread tProdtemp = new Thread(new Runnable() {
@Override
public void run() {
producerTemp();
}
});
public void producerTemp ()
{
for (int i = 0 ; i <504 ; i++)
{
synchronized (lock)
{
while (queue1.size() == 100)
{
try {
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
try {
queue1.put(Float.parseFloat(value[i]));
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
queue2.put(Float.parseFloat(value[i]));
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
queue3.put(Float.parseFloat(value[i]));
} catch (InterruptedException e) {
e.printStackTrace();
}
lock.notify();
System.out.println("Min value: " + consumerMin());
}
}
}