2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
9 import java.util.concurrent.locks.ReentrantLock;
15 public class SpecialLock extends ReentrantLock{
16 private static SpecialLock instance = null;
17 private Transaction ownerTransaction = null;
19 private SpecialLock() {
23 public synchronized void lock(Transaction tr){
25 setOwnerTransaction(tr);
28 public synchronized void unlock(Transaction tr){
30 setOwnerTransaction(null);
33 public synchronized void setOwnerTransaction(Transaction tr){
34 ownerTransaction = tr;
37 public synchronized Transaction getOwnerTransaction(){
38 return ownerTransaction;
41 public synchronized static SpecialLock getSpecialLock(){
42 if (instance == null){
43 instance = new SpecialLock();