ONLY INVOKE WHILE HOLDING THE terminated lock
325161
private boolean addToWebContainer() {
        if (!Thread.holdsLock(terminated)) {
            throw new IllegalStateException();
        }
        synchronized (addRemoveLock) {
            if (installer.installIntoWebContainer(this)) {
                setState(State.DEPLOYED);
                return true;
            } else {
                closeTracker();
                return false;
            }
        }
    }
640340
def lock(self, source_node):
        """"""
        if self.status != self.S_INIT:
            raise ValueError("Trying to lock a task with status %s" % self.status)

        self._status = self.S_LOCKED
        self.history.info("Locked by node %s", source_node)
213355
private void unlock(Object holder) throws PSQLException {
    if (lockedFor != holder) {
      throw new PSQLException(GT.tr("Tried to break lock on database connection"),
          PSQLState.OBJECT_NOT_IN_STATE);
    }
    lockedFor = null;
    this.notify();
  }
593274
function cmd_unlock(args, done) {
    var seneca = this
    cmd_increment_lock(seneca, args.id, true, function(err) {
      if (err) return done(err, { ok: false, why: err })
      done(null, { ok: true })
    })
  }
1330691
def lock(self):
        
        if not self.locked:
            rpc_command = '<Lock/>'
            try:
                self._execute_rpc(rpc_command)
            except XMLCLIError:
                raise LockError('Unable to enter in configure exclusive mode!', self)
            self.locked = True
821764
private void takeCloseLock()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "takeCloseLock");

      while (true)
      {
         try
         {
            closeLock.readLock().lockInterruptibly();
            break;
         }
         catch (InterruptedException e)
         {
            // No FFDC code needed.
         }
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "takeCloseLock");
   }
1113637
def invokeRunnable(self):
        
        runnable = self.runnable
        if runnable is None:
            self.deleteFromStore()
        else:
            try:
                self.running = True
                newTime = runnable.run()
            finally:
                self.running = False
            self._rescheduleFromRun(newTime)
1020623
void lock(String serverId) {
        Assert.notNull(serverId);
        if (this.locked) {
            throw new IllegalStateException("Cannot lock already locked mutex: " + this);
        }
        this.locked = true;
        this.lockStart = new Date();
        this.lastUpdate = this.lockStart;
        this.serverId = serverId;
    }
47451
def _lock(self):
        """"""
        if not self.locked:
            self.device.cu.lock()
            self.locked = True
852014
def invoke(self):
        
        # flush to ensure external process can see flags as they currently
        # are, and write flags (flush releases lock)
        unitdata.kv().flush()
        subprocess.check_call([self._filepath, '--invoke', self._test_output], env=os.environ)
444014
@Override
  public void onCompleted() {
    RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
      @Override
      public OpenLocalBlockResponse call() throws Exception {
        if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
          mWorker.unlockBlock(mLockId);
          mLockId = BlockLockManager.INVALID_LOCK_ID;
        } else if (mRequest != null) {
          LOG.warn("Close a closed block {}.", mRequest.getBlockId());
        }
        return null;
      }

      @Override
      public void exceptionCaught(Throwable e) {
        mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
        mLockId = BlockLockManager.INVALID_LOCK_ID;
      }
    }, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s",
        mSessionId, mRequest);
  }
1279233
public void lock() throws IOException, InterruptedException {
        if (channel == null) {
            initializeChannel();
        }
        lockSem.acquire();
        lock = channel.lock();
    }
147103
def stop(self):
        
        if not DBMutex.objects.filter(id=self.lock.id).exists():
            raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id))
        else:
            self.lock.delete()
868227
@Override
    public void postInvoke(int id, EJSDeployedSupport s) throws RemoteException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.entry(tc, "postInvoke");
        }

        // Release lock acquired if container managed concurrency control.
        if (ivContainerManagedConcurrency && s.ivLockAcquired) {
            // Get the lock type to use for the method being invoked.
            EJBMethodInfoImpl mInfo = s.methodInfo;
            LockType lockType = mInfo.ivLockType;

            if (lockType == LockType.READ) {
                ivReadLock.unlock();

                if (isTraceOn && tc.isDebugEnabled()) {
                    Tr.debug(tc, "postInvoke released read lock: " + ivLock.toString());
                }
            } else {
                ivWriteLock.unlock();

                if (isTraceOn && tc.isDebugEnabled()) {
                    Tr.debug(tc, "postInvoke released write lock: " + ivLock.toString());
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "postInvoke");
        }
    }
83892
def __unLock(self):
        """"""
        self._operation = False
        self._timer = 0
        self._isLocked = False
569435
def interrupt (aggregate):
    """"""
    while True:
        try:
            log.warn(LOG_CHECK,
               _("interrupt; waiting for active threads to finish"))
            log.warn(LOG_CHECK,
               _("another interrupt will exit immediately"))
            abort(aggregate)
            break
        except KeyboardInterrupt:
            pass
49683
def trigger(self):
        """"""
        if _debug: IOCB._debug("trigger(%d)", self.ioID)

        # if it's queued, remove it from its queue
        if self.ioQueue:
            if _debug: IOCB._debug("    - dequeue")
            self.ioQueue.remove(self)

        # if there's a timer, cancel it
        if self.ioTimeout:
            if _debug: IOCB._debug("    - cancel timeout")
            self.ioTimeout.suspend_task()

        # set the completion event
        self.ioComplete.set()
        if _debug: IOCB._debug("    - complete event set")

        # make the callback(s)
        for fn, args, kwargs in self.ioCallback:
            if _debug: IOCB._debug("    - callback fn: %r %r %r", fn, args, kwargs)
            fn(self, *args, **kwargs)