Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2016 21:16
Show Gist options
  • Save anonymous/de3539ad014de2b18c2fc46a4aff946f to your computer and use it in GitHub Desktop.
Save anonymous/de3539ad014de2b18c2fc46a4aff946f to your computer and use it in GitHub Desktop.
def parallelPaper(lines: List[String]): Int = {
val futures: List[Future[Int]] = for (line <- lines) yield parallelCompute(line)
val result = futures.foldLeft(0) { (total, future) =>
{
future.onComplete {
case Success(value) => {
total + value
}
case Failure(e) => e.printStackTrace()
}
total
}
}
Thread.sleep(1000)
result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment