Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
+import java.util.concurrent.ThreadLocalRandom;\r
\r
\r
public class Consommateur implements Runnable {\r
val = (Integer)buffer.preleve();\r
System.out.println (Thread.currentThread().getName() + " a preleve " + val);\r
try {\r
- Thread.sleep((int)(Math.random()*1000));\r
+ Thread.sleep(ThreadLocalRandom.current().nextInt(1001));\r
}\r
catch (InterruptedException e) {}\r
}\r
+import java.util.concurrent.ThreadLocalRandom;\r
\r
\r
public class Producteur implements Runnable {\r
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