public static boolean doLockedAction(Path lockPath, boolean waitForLock,
			Supplier<Boolean> action)
			throws OverlappingFileLockException, UnableToGetLockException {
		try (FileOutputStream fos = new FileOutputStream(lockPath.toFile());
				FileChannel channel = fos.getChannel();
				FileLock lock = waitForLock ? channel.lock() : channel.tryLock();) {
			if (lock == null) {
				throw new UnableToGetLockException();
			}
			return action.get();
		}
		catch (FileLockInterruptionException e) {
			// this is okay, user interrupted locking action
		}
		catch (IOException e) {
			Swing.runNow(
				() -> Msg.showError(GhidraGoIPC.class, null, "Could not perform exclusive action",
					"Another process is currently holding the lock at " + lockPath, e));
		}
		return false;
	}
perform the given action after acquiring the client lock successfully. This method is used
to ensure that only one actor for the given lock path is performing the action.
@param lockPath the path of the file to lock
@param action the action taken after acquiring the lock.
@param waitForLock if true blocks until the lock is acquired. otherwise, if the lock can't be 
acquired, the method returns false and does not do any blocking actions
@return true if the action succeeded. false otherwise.
@throws OverlappingFileLockException if another process currently controls the lock
@throws UnableToGetLockException if the lock was unobtainable
Ghidra/Features/GhidraGo/src/main/java/ghidra/app/plugin/core/go/ipc/GhidraGoIPC.java