public final class ReadWriteProcessLock
extends java.lang.Object
ReentrantReadWriteLock
used to synchronize threads both within the same
process and across different processes. The basic usages involving readLock()
, writeLock()
, ReadWriteProcessLock.Lock.lock()
, and ReadWriteProcessLock.Lock.unlock()
are similar to those of ReentrantReadWriteLock
and Lock
.Modifier and Type | Class and Description |
---|---|
static interface |
ReadWriteProcessLock.Lock |
Modifier and Type | Method and Description |
---|---|
static ReadWriteProcessLock |
getInstance(java.io.File lockFile)
Returns a
ReadWriteProcessLock instance with a lock file as a way to synchronize
execution across processes. |
com.android.ide.common.util.ReadWriteProcessLock.ReadLock |
readLock()
Returns the lock used for reading.
|
com.android.ide.common.util.ReadWriteProcessLock.WriteLock |
writeLock()
Returns the lock used for writing.
|
public static ReadWriteProcessLock getInstance(@NonNull java.io.File lockFile) throws java.io.IOException
ReadWriteProcessLock
instance with a lock file as a way to synchronize
execution across processes. This method guarantees that there is only one ReadWriteProcessLock
instance per process for a given lock file (there could still be
multiple ReadWriteProcessLock
instances on different processes for a given lock
file).
It is strongly recommended that the lock file is used solely for synchronization purposes. The client of this class should not access (read, write, or delete) the lock file. The lock file may or may not exist when this method is called. However, it will be created and will not be deleted once the client starts using the locking mechanism provided by this class. The client may delete the lock files only when the locking mechanism is no longer in use.
lockFile
- the lock file, used solely for synchronization purposesjava.io.IOException
public com.android.ide.common.util.ReadWriteProcessLock.ReadLock readLock()
public com.android.ide.common.util.ReadWriteProcessLock.WriteLock writeLock()