diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index bc78260..407ebfe 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; public class Main { @@ -44,16 +45,23 @@ public class Main { }); AccessPoint.setTimeSlotNb(timeSlotNb); AccessPoint.setSubCarrierNb(subCarrierNb); - 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); - executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); + 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); + executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); + } + executor.shutdown(); + try { + if(!executor.awaitTermination(2, TimeUnit.MINUTES)) { + executor.shutdownNow(); } + } catch (InterruptedException e) { + e.printStackTrace(); } } else { System.err.println("Please give launch arguments");