在Ruby中,我会使用Timeout模块,它执行一个代码块,并且如果超过了设定的时间,就会停止执行该代码块。
Groovy有类似这样的功能吗?
require 'timeout'
status = Timeout::timeout(5) {
# Something that should be interrupted if it takes too much time...
}
Groovy有类似这样的功能吗?