concurrency - Scala - futures does not run -
i trying run following future basic code
future { println("ssss")} onsuccess{ case _ => println("succ")} however, when run main method, nothing console printed , system exits instantly. using implicit executioncontext. hints?
this code:
val f = future(await.ready(promise().future, d.timeleft)) f.onsuccess { case _ => println("hee") } also exits immediately....
futures executed on dedicated thread pool. if main program not wait future, exit , future won't have chance execute. can here use await in main program block main thread until future executes:
def main( args: array[string] ) { val fut = future { println("ssss")} fut onsuccess{ case _ => println("succ")} await.result( fut ) }
Comments
Post a Comment