title: Best way to sequentially pass list values to single value consumer?
body: <p>I'm toying with Java8's streams and <code>CompletableFuture</code>s. My pre-existing code has a class that takes a single URL and downloads it:</p>
  
  <pre><code>public class FileDownloader implements Runnable {
      private URL target;
      public FileDownloader(String target) {
          this.target = new URL(target);
      }
      public void run() { /* do it */ }
  }
  </code></pre>
  
  <p>Now, this class gets it's information from another part that emits <code>List&lt;String&gt;</code> (a number of targets on a single host).</p>
  
  <p>I've switched the surrounding code to <code>CompletableFuture</code>:</p>
  
  <pre><code>public class Downloader {
      public static void main(String[] args) {
          List&lt;String&gt; hosts = fetchTargetHosts();
          for (String host : hosts) {
              HostDownloader worker = new HostDownloader(host);
              CompletableFuture&lt;List&lt;String&gt;&gt; future = 
                  CompletableFuture.supplyAsync(worker);
              future.thenAcceptAsync((files) -&gt; {
                  for (String target : files) {
                      new FileDownloader(target).run();
                  }
              });
          }
      }
  
      public static class HostDownloader implements Supplier&lt;List&lt;String&gt;&gt; {
          /* not shown */ 
      }
      /* My implementation should either be Runnable or Consumer.
         Please suggest based on a idiomatic approach to the main loop.
       */
      public static class FileDownloader implements Runnable, Consumer&lt;String&gt; { 
          private String target;
          public FileDownloader(String target) {
              this.target = target;
          }
  
          @Override
          public void run() { accept(this.target); }
  
          @Override
          public void accept(String target) {
              try (Writer output = new FileWriter("/tmp/blubb")) {
                  output.write(new URL(target).getContent().toString());
              } catch (IOException e) { /* just for demo */ }
          }
      }
  }
  </code></pre>
  
  <p>Now, this doesn't feel natural. I'm producing a stream of <code>String</code>s and my <code>FileDownloader</code> consumes one of them at a time. Is there a readymade to enable my single value <code>Consumer</code> to work with <code>List</code>s or am I stuck with the <code>for</code> loop here?</p>
  
  <p>I know it's trivial to move the loop into the <code>accept</code> and just make a <code>Consumer&lt;List&lt;String&gt;&gt;</code>, that's not the point.</p>