title: This parallelized sum program, using divide-and-conquer, does not terminate
body: <p>I am trying to implement a simple parallel sum of list in Scala. This one below uses divide-and-conquer recursively, but it turns out the program does not terminate. Where is the problem? What is the right way to do this computing?</p>
  
  <pre><code>import java.util.concurrent.{Callable, ExecutorService, Executors, Future}
  
  val es=Executors.newWorkStealingPool()
  
  def sumP(ints: IndexedSeq[Int]): Int = {if (ints.size &lt;= 1)
    ints.headOption getOrElse 0 else {
    val (l, r) = ints.splitAt(ints.length / 2)
    val fut_l = es.submit(new Callable[Int] {
      override def call = sumP(l)
    })
    val fut_r = es.submit(new Callable[Int]  {
      override def call = sumP(r)
    })
    fut_l.get() + fut_r.get()
  }}
  println("result is here: ")
  val res=sumP(1 to 4000000)
  </code></pre>