Skip to content

Instantly share code, notes, and snippets.

@AntonFagerberg
Created August 7, 2013 07:17
Show Gist options
  • Save AntonFagerberg/6171895 to your computer and use it in GitHub Desktop.
Save AntonFagerberg/6171895 to your computer and use it in GitHub Desktop.
Play concurrency test
package controllers
import play.api._
import play.api.mvc._
import scala.concurrent.{ExecutionContext, Future}
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.ws.WS
object Application extends Controller {
def index = Action {
println("Start")
val wait = Future {
println("Future start")
for (i <- 0 to 100000000) { Math.pow(i, 3) }
println("Future done")
}
Async {
println("Async")
wait.map { w =>
println("Done")
Ok(views.html.index("Your new application is ready."))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment