def check(){
println"start first"
Domain1 domain1=Domain1.get(1);
domain1.lock();
println "locking started"
sleep(20*60)
println "save first"
domain1.name="hari ram"
domain1.save();
println "save first completed"
}
def check2(){
try {
println"start second"
Domain1 domain1=Domain1.get(1);
println"save second"
domain1.name="hari ram -------------------++++++++"
domain1.save(flush:true,failOnError:true);
println "save second completed"
}
catch(Exception ex){
ex.each{
println "error ${ex}"
}
}
}
我上面代码的日志是:
start first
locking started
start second
save second
save second completed
save first
save first completed
并且数据库也会更新。为什么 lock() 不起作用?不是在lock() 之后其他实例无法更新吗?或者是别的什么?还是我错过了什么?