Remove try-with-resources to make it work with jdk 1.8

This commit is contained in:
Quentin Legot 2023-04-04 08:57:40 +02:00
parent 5597bfa93e
commit 05d51acdc0

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class Main { public class Main {
@ -44,7 +45,7 @@ public class Main {
}); });
AccessPoint.setTimeSlotNb(timeSlotNb); AccessPoint.setTimeSlotNb(timeSlotNb);
AccessPoint.setSubCarrierNb(subCarrierNb); AccessPoint.setSubCarrierNb(subCarrierNb);
try(ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) { ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
for(int i = 2; i <= maximumLoad; i += 2) { for(int i = 2; i <= maximumLoad; i += 2) {
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb); List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
@ -54,6 +55,13 @@ public class Main {
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users); AccessPoint accessPoint = new AccessPoint(scheduler, frame, users);
executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
} }
executor.shutdown();
try {
if(!executor.awaitTermination(2, TimeUnit.MINUTES)) {
executor.shutdownNow();
}
} catch (InterruptedException e) {
e.printStackTrace();
} }
} else { } else {
System.err.println("Please give launch arguments"); System.err.println("Please give launch arguments");