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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -