title: Java - Runnable, lambda function, and methods of class
body: <p>I'm quite new with Java (studied on University but was version 2).
  Now I've developed an application that downloads files from s3 in parallel. I've used <code>ExecutorService</code> and <code>Runnable</code> to download multiple files in parallel in this way:</p>
  
  <pre><code>public class DownloaderController {
      private AmazonS3 s3Client;
      private ExecutorService fixedPool;
      private TransferManager dlManager;
      private List&lt;MultipleFileDownload&gt; downloads = new ArrayList&lt;&gt;();
      public DownloaderController() {
          checkForNewWork();
      }
      public void checkForNewWork(){
          Provider1 provider = new Provider1();
          fixedPool = Executors.newFixedThreadPool(4);
          List&lt;Download&gt; providedDownloadList = provider.toBeDownloaded();
              for (Download temp : providedDownloadList) {
                  if (!downloadData.contains(temp)) {
                      fixedPool.submit(download.downloadCompletedHandler(s3Client));
                  }
              }
          }
      }
      public void printToTextArea(String msg){
          Date now = new Date();
          if ( !DateUtils.isSameDay(this.lastLogged, now)){
              this._doLogRotate();
          }
          this.lastLogged = now;
          SimpleDateFormat ft = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
          String output = "[ " + ft.format(now) + " ] " + msg + System.getProperty("line.separator");
          Platform.runLater(() -&gt; {
              //this is a FXML object
              statusTextArea.appendText(output);
          });
      }
  }
  
  public class Provider1 implements downloadProvider {
  
  }
  
  public class Download {
      abstract Runnable downloadCompletedHandler(AmazonS3 s3Client);
  }
  
  public class DownloadProvider1 extends Download {
      @Override
      public Runnable downloadCompletedHandler(AmazonS3 s3Client){
          Runnable downloadwork = () -&gt; {
              ObjectListing list = s3Client.listObjects(this.bucket,this.getFolder());
              List&lt;S3ObjectSummary&gt; objects = list.getObjectSummaries();
              AtomicLong workSize = new AtomicLong(0);
              List&lt;DeleteObjectsRequest.KeyVersion&gt; keys = new ArrayList&lt;&gt;();
              objects.forEach(obj -&gt; {
                  workSize.getAndAdd(obj.getSize());
                  keys.add((new DeleteObjectsRequest.KeyVersion(obj.getKey())));
              });
              MultipleFileDownload fileDownload = dlManager.downloadDirectory("myBucket","folder","outputDirectory");
              try {
                  fileDownload.waitForCompletion();
              } catch (Exception e){
                  printToTextArea("Exception while download from AmazonS3");
              }   
          };
          return downloadwork;
      }
  }
  </code></pre>
  
  <p>In the downloadController i call every minute a function that adds some Download objects to a List that contains folders that has to be downloaded from s3. when a new Download is added it's also added to ExecutorService pool. The Download object returns the code that has to be executed to download the folder from s3 and what to do when it's download is finished.
  My problem is, what is the best way to communicate between the Runnable and the DownloadController ? </p>