private void acquireGlobalWriteLock(TxId txId) throws InterruptedException
    {
        // Get the global write lock to ensure only one thread at a time can execute this code.
        globalLock.writeLock().lock();

        // Use a try block so that the corresponding finally block guarantees release of the thread lock.
        try
        {
            // Check that this transaction does not already own the lock.
            if (!txId.equals(globalWriteLockTxId))
            {
                // Wait until the write lock becomes free.
                while (globalWriteLockTxId != null)
                {
                    globalWriteLockFree.await();
                }

                // Assign the global write lock to this transaction.
                globalWriteLockTxId = txId;
            }
        }
        finally
        {
            // Ensure that the thread lock is released once assignment of the write lock to the transaction is complete.
            globalLock.writeLock().unlock();
        }
    }
private void acquireGlobalWriteLock(TxId txId) throws InterruptedException
    {
        
        globalLock.writeLock().lock();

        
        try
        {
            
            if (!txId.equals(globalWriteLockTxId))
            {
                
                while (globalWriteLockTxId != null)
                {
                    globalWriteLockFree.await();
                }

                
                globalWriteLockTxId = txId;
            }
        }
        finally
        {
            
            globalLock.writeLock().unlock();
        }
    }
private void acquireGlobalWriteLock ( TxId txId ) throws InterruptedException { // Get the global write lock to ensure only one thread at a time can execute this code. globalLock . writeLock ( ) . lock ( ) ; // Use a try block so that the corresponding finally block guarantees release of the thread lock. try { // Check that this transaction does not already own the lock. if ( ! txId . equals ( globalWriteLockTxId ) ) { // Wait until the write lock becomes free. while ( globalWriteLockTxId != null ) { globalWriteLockFree . await ( ) ; } // Assign the global write lock to this transaction. globalWriteLockTxId = txId ; } } finally { // Ensure that the thread lock is released once assignment of the write lock to the transaction is complete. globalLock . writeLock ( ) . unlock ( ) ; } }
Waits until the global write lock can be acquired by the specified transaction.

@param  txId The transaction id to acquite the global write lock for.

@throws InterruptedException If interrupted whilst waiting for the global write lock.
Waits until the global write lock can be acquired by the specified transaction .