Studying parallelism in Scala, I have got an impression that Futures and executor tasks are like lightweight threads. You can create more them than there are threads. But I get an OOM exception running the following code
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{Future, future, Await}
import scala.concurrent.duration._
def fib(n: Int): Future[Int] = future {if (n < 2) n else
List(n-1, n-2) map fib map {Await.result(_, Duration.Inf)} sum};
Await.result(fib(35), Duration.Inf)
What is happening?