title: Understanding Spark async actions
body: <p>I have a Java code for Spark:</p>
  
  <pre><code>    SparkConf sparkConf = new SparkConf().set("spark.scheduler.mode", "FAIR");
      JavaSparkContext sc = new JavaSparkContext("local","MyAppName", sparkConf);
  
      JavaPairRDD&lt;String, String&gt; wholeTextFiles1 = sc.wholeTextFiles("/path1/*");
      JavaPairRDD&lt;String, String&gt; wholeTextFiles2 = sc.wholeTextFiles("/path2/*");
  
      JavaFutureAction&lt;Void&gt; voidJavaFutureAction = wholeTextFiles1.foreachAsync(new VoidFunction&lt;Tuple2&lt;String, String&gt;&gt;() {
          public void call(Tuple2&lt;String, String&gt; stringStringTuple2) throws Exception {
              //do something
          }
      });
  
      JavaFutureAction&lt;Void&gt; voidJavaFutureAction1 = wholeTextFiles2.foreachAsync(new VoidFunction&lt;Tuple2&lt;String, String&gt;&gt;() {
          public void call(Tuple2&lt;String, String&gt; stringStringTuple2) throws Exception {
              //do something
          }
      });
  
      voidJavaFutureAction.get();
      voidJavaFutureAction1.get();
  </code></pre>
  
  <p>There is two <code>foreachAsync</code> actions. I'm waiting spark to do two different actions in the same time. But in spark application UI, I see 2 stages, but one of this waits for start until the other one finishes. I'm waiting to two different stages works same time, am I wrong? How <code>foreachAsync</code> works?</p>