TD1: Use thread optimized random number generator.
[TD_SR.git] / TD1 / exo3 / Producteur.java
CommitLineData
aee04a83 1import java.util.concurrent.ThreadLocalRandom;\r
396bc743
JB
2\r
3\r
4public class Producteur implements Runnable {\r
5\r
6 private BufferCirc buffer;\r
7 private int val;\r
8\r
9\r
10 public Producteur(BufferCirc b) {\r
11 buffer = b;\r
12 }\r
13\r
14\r
15 public void run() {\r
16 while (true) {\r
17 buffer.depose(new Integer(val));\r
18 System.out.println (Thread.currentThread().getName() + " a depose " + val);\r
19 val++;\r
20 try {\r
aee04a83 21 Thread.sleep(ThreadLocalRandom.current().nextInt(101));\r
396bc743
JB
22 }\r
23 catch (InterruptedException e) {}\r
24 }\r
25 }\r
26\r
27} // fin classe Producteur\r