目前常用的有三种实现方式
1:基于redis的实现
2:基于zk的实现
3:基于db的实现
final DbDistributedLockTemplate template = new DbDistributedLockTemplate();
public void init(){
template.execute("shchgateway", 2000, new Callback() {
@Override
public Object onTimeout() throws InterruptedException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object onGetLock() throws InterruptedException {
// TODO Auto-generated method stub
return null;
}
});
}