TD1: Initial commit of exercice 3 code.
[TD_SR.git] / TD1 / exo3 / Consommateur.java
... / ...
CommitLineData
1\r
2\r
3public class Consommateur implements Runnable {\r
4\r
5 private BufferCirc buffer;\r
6\r
7\r
8 public Consommateur(BufferCirc b) {\r
9 buffer = b;\r
10 }\r
11\r
12\r
13 public void run() {\r
14 Integer val;\r
15 while (true) {\r
16 val = (Integer)buffer.preleve();\r
17 System.out.println (Thread.currentThread().getName() + " a preleve " + val);\r
18 try {\r
19 Thread.sleep((int)(Math.random()*1000));\r
20 }\r
21 catch (InterruptedException e) {}\r
22 }\r
23 }\r
24\r
25} // fin classe Consommateur\r