Skip to content

Instantly share code, notes, and snippets.

@tohenryliu
Created June 23, 2014 19:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tohenryliu/d358c09b5c63a65e47e2 to your computer and use it in GitHub Desktop.
Save tohenryliu/d358c09b5c63a65e47e2 to your computer and use it in GitHub Desktop.
lazy val in def blocks
def test = {
lazy val x = {
println(s"lazy compute called")
Thread.sleep(1000*30)
1
}
x
}
def mRun = {
import scala.concurrent.ExecutionContext.Implicits.global
val fs = (1 to 10).toList.map{n=>
Future{
test
}
}
val f = Future.sequence(fs)
Await.result(f, Duration.Inf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment