+ static LinkedList<AltosMapStore> waiting = new LinkedList<AltosMapStore>();
+ static LinkedList<AltosMapStore> running = new LinkedList<AltosMapStore>();
+
+ static final int concurrent_fetchers = 128;
+
+ static void start_fetchers() {
+ while (!waiting.isEmpty() && running.size() < concurrent_fetchers) {
+ AltosMapStore s = waiting.remove();
+ running.add(s);
+ Thread lt = s.make_fetcher_thread();
+ lt.start();
+ }
+ }
+
+ void finish_fetcher() {
+ synchronized(fetcher_lock) {
+ running.remove(this);
+ start_fetchers();
+ }
+ }
+
+ void add_fetcher() {
+ synchronized(fetcher_lock) {
+ waiting.add(this);
+ start_fetchers();
+ }
+ }
+
+ class fetcher implements Runnable {