Ugly implementation. Looks slower?!
This commit is contained in:
parent
fc05264a46
commit
82efe228d3
@ -1,4 +1,5 @@
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
public class MakkahCity {
|
public class MakkahCity {
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ public class MakkahCity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
clearDoneCivilVehicles();
|
clearDoneCivilVehicles();
|
||||||
|
ArrayList<Thread> threadPool = new ArrayList<>();
|
||||||
for (Vehicle vehicle : listOfVehicles) {
|
for (Vehicle vehicle : listOfVehicles) {
|
||||||
Route route = vehicle.getRoute();
|
Route route = vehicle.getRoute();
|
||||||
double currentLocation = vehicle.getCurrentLocation();
|
double currentLocation = vehicle.getCurrentLocation();
|
||||||
@ -81,6 +83,8 @@ public class MakkahCity {
|
|||||||
vehicle.moveToNextStreet();
|
vehicle.moveToNextStreet();
|
||||||
}
|
}
|
||||||
if (!vehicle.isArrivedToDest()) {
|
if (!vehicle.isArrivedToDest()) {
|
||||||
|
Thread t = new Thread(() -> {
|
||||||
|
try {
|
||||||
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
||||||
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
||||||
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||||
@ -88,6 +92,21 @@ public class MakkahCity {
|
|||||||
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
||||||
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
threadPool.add(t);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Thread t : threadPool) {
|
||||||
|
try {
|
||||||
|
t.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//noise based on time of day (From PDate)
|
//noise based on time of day (From PDate)
|
||||||
|
Loading…
Reference in New Issue
Block a user