title: Which is the best way to set/drop boolean flag inside lambda function
body: <p>Say I have a currency rates loader returning <code>isLoaded=true</code> result only when all the rates are loaded successfully:</p>
  
  <pre><code>//List&lt;String&gt; listFrom = Stream.of("EUR", "RUB").collect(toList());
  //List&lt;String&gt; listTo = Stream.of("EUR", "CNY").collect(toList());
  
  boolean isLoaded = true;
  
  final FixerDataProvider httpProvider = new FixerDataProvider(maxAttempts);
  final List&lt;CurrencyRatePair&gt; data =
      listFrom.stream()
          .flatMap(from -&gt; {
              final List&lt;CurrencyRatePair&gt; result = httpProvider.findRatesBetweenCurrencies(from, listTo);
              if (Objects.isNull(result) || result.size() == 0) {
                  isLoaded = false; //!!!Not working as ineffectively final!!!
              }
              return result.stream();
          }).collect(Collectors.toList());
  
  if (!isLoaded) {
      return false;
  }
  
  // do smth with loaded data 
  
  return true;
  </code></pre>
  
  <p>Assignment <code>isLoaded = false;</code> inside lambda function is not allowed when <code>isLoaded</code> variable is not final or effectively final. </p>
  
  <p><strong>Which is the most elegant solution to set/drop boolean flag inside lambda expressions?</strong></p>
  
  <p><strong>What do you think about AtomicBoolean and set(false) method as a possible approach?</strong></p>