There is an annotation TimedInterrupt , but I have not tried it yet ...
Give it a quick test, and this one (bad example):
@groovy.transform.TimedInterrupt( 5L )
def loopy() {
int i = 0
try {
while( true ) {
i++
}
}
catch( e ) {
i
}
}
println loopy()
Runs in the groovy console and displays iafter 5 seconds.
I get:
47314150
source
share