Scala - futures does not run

I am trying to run the following future basic code

 future { println("ssss")} onSuccess{ case _ => println("succ")}

However, when I run the main method, nothing to the console is printed and the system exits almost instantly. I am using the implicit ExecutionContext. Any hints?

This code:

  val f = future(Await.ready(Promise().future, d.timeLeft))

   f.onSuccess {
     case _ => println("hee")

also exits immediately....


Futures are executed on a dedicated thread pool. If your main program does not wait for the future, it will exit immediately and the future won't have a chance to execute. What you can do here is to use Await in your main program to block the main thread until the future executes:

def main( args: Array[String] ) {
  val fut = future { println("ssss")}
  fut onSuccess{ case _ => println("succ")}
  Await.result( fut )

Need Your Help

MS Access VBA code not deleteing all records

mysql vba ms-access

I'm trying to delete all the records of one table that appear in another, however it only seems to delete some of the records.

How do you run javascript with only a CSS class?

javascript html css json

I am working on a web site project which requires that the web page display tooltips on hover. For reasons I won't go into here, I decided to use a library from a site called The libr...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.