Skip to content
Snippets Groups Projects
Commit ca61eacd authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #131 failed with stages
in 22 seconds
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
package de.itstall;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Thread> threadList = new ArrayList<>();
int ausfuehrungen = 25;
try {
Thread.sleep(20000);
} catch (InterruptedException ignored) {
}
System.out.println("Starte Messung");
long start = System.currentTimeMillis();
for (int i = 0; i < ausfuehrungen; i++) {
Thread th = new Thread(new Summierer(i));
th.start();
threadList.add(th);
}
for (Thread thread : threadList) {
try {
thread.join();
} catch (InterruptedException ignored) {
}
}
long dauer = System.currentTimeMillis() - start;
System.out.println("Dauer der Abfertigung: " + dauer + " Milisekunden");
}
}
package de.itstall;
public class Summierer implements Runnable {
public int threadNumber;
public Summierer(int threadNumber) {
this.threadNumber = threadNumber;
}
@Override
public void run() {
int i = 0;
while(i < Integer.MAX_VALUE) {
i++;
if((i % 250000000 == 0)) {
System.out.println("Zwischenergebnis " + this.threadNumber + ": " + i);
}
}
System.out.println("Thread " + this.threadNumber + ": " + i);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment