Created
June 23, 2014 19:57
-
-
Save tohenryliu/d358c09b5c63a65e47e2 to your computer and use it in GitHub Desktop.
lazy val in def blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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