commit
commit
1be36c50dc
|
@ -0,0 +1,29 @@
|
|||
import java.util.Random;
|
||||
|
||||
public class MyThreadLocalRandom implements Runnable {
|
||||
public static long now;
|
||||
public Random rand;
|
||||
//TODO Nochmal anschauen
|
||||
public MyThreadLocalRandom (long now) {
|
||||
this.now = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
rand = new Random(5);
|
||||
var strBuf = new StringBuffer();
|
||||
strBuf.append(Thread.currentThread().getName() + ": ");
|
||||
for (var j = 0; j < 20; j++) {
|
||||
strBuf.append(String.format("%2d ", this.rand.nextInt(100)));
|
||||
}
|
||||
System.out.println(strBuf);
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
long now = System.currentTimeMillis();
|
||||
var runner = new MyThreadLocalRandom(now);
|
||||
for (var i = 0; i < 10; i++) {
|
||||
new Thread(runner, String.format("Runner-%02d", i)).start();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue