diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index cccfd09..b5d412d 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -7,6 +7,8 @@ import fr.ntr.scheduler.Scheduler; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class Main { @@ -26,17 +28,18 @@ public class Main { } int timeSlotNb = 2; int subCarrierNb = 100; - for(int i = 2; i <= maximumLoad; i += 2) { - List users = generateUsers(i, timeSlotNb, subCarrierNb); - ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; - //Scheduler scheduler = new MaxSNR(frame, users); - // Scheduler scheduler = new ProportionalFair(frame, users); - Scheduler scheduler = new RoundRobin(frame, users); - AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50); - accessPoint.startSimulation(numberOfTicks); + try(ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) { + for(int i = 2; i <= maximumLoad; i += 2) { + List users = generateUsers(i, timeSlotNb, subCarrierNb); + ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; + //Scheduler scheduler = new MaxSNR(frame, users); + // Scheduler scheduler = new ProportionalFair(frame, users); + Scheduler scheduler = new RoundRobin(frame, users); + AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50); + executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); + } } - } - else { + } else { System.err.println("Please give launch arguments"); System.err.println("gradle run --args=\" \""); System.exit(1);