+
+ Map<Long, Network> timesForNextConnects = new TreeMap<>(missingNetworks.stream()
+ .collect(Collectors.toMap(connectionBackoff::getBackoff, Function.identity(), (network, ignore) -> network)));
+
+ Entry<Long, Network> firstNetwork = timesForNextConnects.entrySet().stream().findFirst().get();
+ if (firstNetwork.getKey() > 0) {
+ eventBus.post(new GenericMessage(String.format("Waiting %d seconds to connect to %s...", TimeUnit.MILLISECONDS.toMinutes(firstNetwork.getKey()), firstNetwork.getValue().name())));
+ synchronized (syncObject) {
+ try {
+ syncObject.wait(firstNetwork.getKey());
+ } catch (InterruptedException ie1) {
+ /* ignore. */
+ }
+ }
+ if (!isRunning()) {
+ break;
+ }
+ }
+
+ connectNetwork(firstNetwork.getValue());