+ static Object loader_lock = new Object();
+
+ static LinkedList<AltosMapStore> waiting = new LinkedList<AltosMapStore>();
+ static LinkedList<AltosMapStore> running = new LinkedList<AltosMapStore>();
+
+ static final int concurrent_loaders = 128;
+
+ static void start_loaders() {
+ while (!waiting.isEmpty() && running.size() < concurrent_loaders) {
+ AltosMapStore s = waiting.remove();
+ running.add(s);
+ Thread lt = s.make_loader_thread();
+ lt.start();
+ }
+ }
+
+ void finish_loader() {
+ synchronized(loader_lock) {
+ running.remove(this);
+ start_loaders();
+ }
+ }
+
+ void add_loader() {
+ synchronized(loader_lock) {
+ waiting.add(this);
+ start_loaders();
+ }
+ }
+