Skip to content

Instantly share code, notes, and snippets.

@mathhun
Created July 12, 2016 01:13
Show Gist options
  • Save mathhun/4c76441b101e1b2c67848ac9cced140e to your computer and use it in GitHub Desktop.
Save mathhun/4c76441b101e1b2c67848ac9cced140e to your computer and use it in GitHub Desktop.
FutureAwait.scala
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.sys.process._
object Main extends App {
"date +start:%H:%M:%S".!
val fx = Future { println(1); Thread.sleep(6000); "date +x%H:%M:%S".!; 1 }
val fy = Future { println(2); Thread.sleep(4000); "date +y%H:%M:%S".!; 2 }
Await.result(fx, Duration.Inf)
Await.result(fy, Duration.Inf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment