main
2wenty1ne 2024-10-15 16:10:41 +02:00
commit 1be36c50dc
1 changed files with 29 additions and 0 deletions

View File

@ -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();
}
}
}