sqlite/sqlite-framework/src/main/java/androidx/sqlite/util/ProcessLock.java
/**
     * Attempts to grab the lock, blocking if already held by another thread or process.
     *
     * @param processLock whether to use file for process level locking or not.
     */
Attempts to grab the lock, blocking if already held by another thread or process.
@param processLock whether to use file for process level locking or not.
Attempts to grab the lock blocking if already held by another thread or process . @param processLock whether to use file for process level locking or not .
public void lock(boolean processLock) {
        mThreadLock.lock();
        if (processLock) {
            try {
                File parentDir = mLockFile.getParentFile();
                if (parentDir != null) {
                    parentDir.mkdirs();
                }
                mLockChannel = new FileOutputStream(mLockFile).getChannel();
                mLockChannel.lock();
            } catch (IOException e) {
                mLockChannel = null;
                Log.w(TAG, "Unable to grab file lock.", e);
            }
        }
    }
public void lock ( boolean processLock ) { mThreadLock . lock ( ) ; if ( processLock ) { try { File parentDir = mLockFile . getParentFile ( ) ; if ( parentDir != null ) { parentDir . mkdirs ( ) ; } mLockChannel = new FileOutputStream ( mLockFile ) . getChannel ( ) ; mLockChannel . lock ( ) ; } catch ( IOException e ) { mLockChannel = null ; Log . w ( TAG , "Unable to grab file lock." , e ) ; } } }
Attempts to grab the lock, blocking if already held by another thread or process.
Attempts to grab the lock blocking if already held by another thread or process .
// Verify parent dir