fork download
  1. object Main extends App {
  2. import scala.concurrent._
  3. import scala.concurrent.duration._
  4.  
  5. import ExecutionContext.Implicits.global
  6.  
  7. def foo(f: Future[Unit]) {
  8. Await.result(f, 0.nanos)
  9. println("foo")
  10. }
  11.  
  12. def bar() {
  13. println("bar")
  14. }
  15.  
  16. foo(Future {
  17. println("F start")
  18.  
  19. val r = new scala.util.Random()
  20.  
  21. for (i <- 1 to 1000) {
  22. r.nextLong
  23. }
  24.  
  25. println("F stop")
  26. })
  27.  
  28. bar()
  29. }
Success #stdin #stdout 0.48s 322560KB
stdin
Standard input is empty
stdout
F start
F stop
foo
bar