X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD1%2Fexo3%2FConsommateur.java;h=7aa8f3004d90a4ebc5fbc62e0c12f8be4d22d7ac;hb=aee04a83cc5eecb50f85e71c4dbfc3ec2bf3cf69;hp=5a548813f2add051d965d812369aba355b257d04;hpb=396bc7433aa7fc3c404f2d175d1c93b82791cdde;p=TD_SR.git diff --git a/TD1/exo3/Consommateur.java b/TD1/exo3/Consommateur.java index 5a54881..7aa8f30 100644 --- a/TD1/exo3/Consommateur.java +++ b/TD1/exo3/Consommateur.java @@ -1,3 +1,4 @@ +import java.util.concurrent.ThreadLocalRandom; public class Consommateur implements Runnable { @@ -16,7 +17,7 @@ public class Consommateur implements Runnable { val = (Integer)buffer.preleve(); System.out.println (Thread.currentThread().getName() + " a preleve " + val); try { - Thread.sleep((int)(Math.random()*1000)); + Thread.sleep(ThreadLocalRandom.current().nextInt(1001)); } catch (InterruptedException e) {} }