Creating a TimerTask
can not get easier than this thanks to groovy.
import java.util.timer.*
is not required as java.util is already imported.- the
run()
is implemented as closure
def count = 0 | |
new Timer().schedule({ | |
println count++ | |
} as TimerTask, 1000, 3000) //magic numbers are initial-delay & repeat-interval |