X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD1%2Fexo3%2FConsommateur.java;h=128249940e41c1ef71f8521eed41b23bba1bcdcd;hb=HEAD;hp=480134976bcecd810a20ae7db3fdfbdfc4fb0eb4;hpb=18eb400ba6dc197a9be104038fa60055bcd83813;p=TD_SR.git diff --git a/TD1/exo3/Consommateur.java b/TD1/exo3/Consommateur.java index 4801349..1282499 100644 --- a/TD1/exo3/Consommateur.java +++ b/TD1/exo3/Consommateur.java @@ -9,24 +9,26 @@ public class Consommateur implements Runnable { buffer = b; } - public Consommateur(BufferCirc b, String name) { + public Consommateur(BufferCirc b, Thread th, String name) { buffer = b; - setThName(name); + setThName(th, name); } - public void setThName(String name) { - Thread.currentThread().setName(name); + public void setThName(Thread th, String name) { + th.setName(name); } public void run() { Integer val; while (true) { val = (Integer)buffer.preleve(); - System.out.println (Thread.currentThread().getName() + " a preleve " + val); + System.out.println(Thread.currentThread().getName() + " a preleve " + val); try { Thread.sleep(ThreadLocalRandom.current().nextInt(1001)); } - catch (InterruptedException e) {} + catch (InterruptedException e) { + System.err.println("InterruptedException: " + e); + } } }