Closed WJSchakel closed 4 months ago
Synchronization was not the issue. The random selection of a GTU number int i
is drawn with upper bound inclusive, it was assumed exclusive. The upper bound also needs to be at least 1. Therefore the following code is now used:
int n = getNetwork().getGTUs().size();
int i = n <= 1 ? 0 : StrategiesDemo.this.stream.nextInt(0, n - 1);
The following code creates a
NoSuchElementException
in the for loop when the number of vehicles is reduced. Synchronizing the method may work, as this code may remove a GTU which a previous call then still needs to loop towards.