TD1: Use thread optimized random number generator.
[TD_SR.git] / TD1 / exo3 / Producteur.java
index 10eab6d55ec99bc5e25278842a1b1a5e30a6a8a6..d836af2a754f29d0d25d76e0413cf456cbe0e99b 100644 (file)
@@ -1,3 +1,4 @@
+import java.util.concurrent.ThreadLocalRandom;\r
 \r
 \r
 public class Producteur implements Runnable {\r
@@ -17,7 +18,7 @@ public class Producteur implements Runnable {
                        System.out.println (Thread.currentThread().getName() +  " a depose " + val);\r
                        val++;\r
                        try {\r
-                               Thread.sleep((int)(Math.random()*100));\r
+                               Thread.sleep(ThreadLocalRandom.current().nextInt(101));\r
                        }\r
                        catch (InterruptedException e) {}\r
                }\r