From 05d51acdc0a494802955dd5a2d2459f13330a16e Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 4 Apr 2023 08:57:40 +0200 Subject: [PATCH] Remove try-with-resources to make it work with jdk 1.8 --- src/main/java/fr/ntr/Main.java | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) 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");