repositories
/
TD_SR.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TD1: Use thread optimized random number generator.
[TD_SR.git]
/
TD1
/
exo3
/
Producteur.java
diff --git
a/TD1/exo3/Producteur.java
b/TD1/exo3/Producteur.java
index 10eab6d55ec99bc5e25278842a1b1a5e30a6a8a6..d836af2a754f29d0d25d76e0413cf456cbe0e99b 100644
(file)
--- a/
TD1/exo3/Producteur.java
+++ b/
TD1/exo3/Producteur.java
@@
-1,3
+1,4
@@
+import java.util.concurrent.ThreadLocalRandom;
\r
\r
\r
public class Producteur implements Runnable {
\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
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
}
\r
catch (InterruptedException e) {}
\r
}
\r