Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import ratpack.exec.Blocking
import ratpack.handling.Context
import ratpack.groovy.test.embed.GroovyEmbeddedApp
@GrabResolver(name = 'jcenter', root = '')
GroovyEmbeddedApp app = GroovyEmbeddedApp.of {
handlers {
all { Context context ->
println "A. Original compute thread: ${Thread.currentThread().name}"
Blocking.exec { ->
context.render "hello from blocking" // pretend blocking work
println "B. Blocking thread : ${Thread.currentThread().name}"
println "C. Original compute thread: ${Thread.currentThread().name}"
}.test {
assert getText() == "hello from blocking"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment