Fix for jdk 1.8

This commit is contained in:
Remi Boure 2023-03-31 10:01:11 +02:00
parent df77238cc9
commit 9936d4f1b9
2 changed files with 27 additions and 20 deletions

View File

@ -12,6 +12,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 {
@ -52,7 +53,7 @@ public class Main {
});
Cell.setTimeSlotNb(timeSlotNb);
Cell.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) {
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
@ -72,7 +73,13 @@ public class Main {
System.exit(1);
}
}
executor.shutdown();
try {
executor.awaitTermination(2, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
}
executor.shutdownNow();
} else {
System.err.println("Please give launch arguments");
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");

View File

@ -45,9 +45,9 @@ public class User {
public void createPackets(int m, int ticks) {
timeInterval--;
if(timeInterval == 0) {
timeInterval = random.nextInt(50, 101);
timeInterval = 50 + random.nextInt(51);
// On tire un nombre entre 0 et 2 * m
mbis = random.nextInt(1, 2 * m + 1) ;
mbis = 1 + random.nextInt(2 * m + 1) ;
}
// On calcule le nombre de paquets qu'on peut transmettre