THIS ASSUMES THAT IT IS CALLED ON A THREAD HOLDING THE LOCK ON THE HeartBeatManager.
557443
private void handleContextException(final ContextClientCodeException e) {

    LOG.log(Level.SEVERE, "ContextClientCodeException", e);

    final ByteString exception = ByteString.copyFrom(this.exceptionCodec.toBytes(e.getCause()));

    final ReefServiceProtos.ContextStatusProto.Builder contextStatusBuilder =
        ReefServiceProtos.ContextStatusProto.newBuilder()
            .setContextId(e.getContextID())
            .setContextState(ReefServiceProtos.ContextStatusProto.State.FAIL)
            .setError(exception);

    if (e.getParentID().isPresent()) {
      contextStatusBuilder.setParentId(e.getParentID().get());
    }

    final ReefServiceProtos.ContextStatusProto contextStatus = contextStatusBuilder.build();

    LOG.log(Level.SEVERE, "Sending heartbeat: {0}", contextStatus);

    this.heartBeatManager.sendContextStatus(contextStatus);
  }
358630
private void setHeartbeatInterval(long heartbeatInterval,
                                    long heartbeatRecheckInterval) {
    this.heartbeatInterval = heartbeatInterval;
    this.heartbeatRecheckInterval = heartbeatRecheckInterval;
    this.heartbeatExpireInterval = 2 * heartbeatRecheckInterval +
      10 * heartbeatInterval;
    ReplicationConfigKeys.blockInvalidateLimit =
      Math.max(ReplicationConfigKeys.blockInvalidateLimit,
               20 * (int) (heartbeatInterval/1000L));
    
  }
50052
public void start() {
    syncLock.lock();
    try {
      if (!this.isConfigured) {
        return;
      }
      instanceChangeStreamListener.stop();
      if (listenersEnabled) {
        instanceChangeStreamListener.start();
      }

      if (syncThread == null) {
        syncThread = new Thread(
            new DataSynchronizerRunner(
              new WeakReference<>(this),
              networkMonitor,
              logger
            ),
            "dataSynchronizerRunnerThread"
        );
      }
      if (syncThreadEnabled && !isRunning) {
        syncThread.start();
        isRunning = true;
      }
    } finally {
      syncLock.unlock();
    }
  }
756002
public void asyncOperationStarted() {
    if (syncThread == Thread.currentThread()) {
      synchronized (entry) {
        while (entry.isProcessing()) {
          try {
            entry.wait();
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
        }
      }
    } else {
      entryLocked = false;
    }
  }
109698
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      // If we are exclusively locked, then just return, as long as
      // the thread that is calling is the thread that holds the
      // exclusive lock.
      if (iExclusivelyLocked && iExclusiveLockHolder == Thread.currentThread())
      {
        if (tc.isEntryEnabled())
          SibTr.exit(tc, "unlock");
        return;
      }

      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (--iLockCount == 0)
        notifyAll();
        
      if (iLockCount < 0)
      {      
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.LockManager",
            "1:196:1.19" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.LockManager",
              "1:203:1.19" },
            null));
      }        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
327922
@Override
    @SuppressWarnings({ "PMD.EmptySynchronizedBlock", "PMD.EmptyCatchBlock",
        "PMD.AvoidCatchingThrowable" })
    public void run() {
        try {
            registerAsGenerator();
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    selector.select();
                    Set<SelectionKey> selected = selector.selectedKeys();
                    for (SelectionKey key : selected) {
                        ((NioHandler) key.attachment())
                            .handleOps(key.readyOps());
                    }
                    selected.clear();
                    synchronized (selectorGate) {
                        // Delay next iteration if another thread has the lock.
                        // "Find bugs" complains, but this is really okay.
                    }
                } catch (InterruptedIOException | InterruptedException
                        | Error e) {
                    break;
                } catch (Throwable e) {
                    // Ignore anything else, this loop is crucial.
                }
            }
        } finally {
            unregisterAsGenerator();
        }
    }
750374
async def post_heartbeat(self, msg, _context):
        """"""

        name = msg.get('name')

        await self.service_manager.send_heartbeat(name)
1155483
public synchronized void unlock() throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "unlock", this);

        // If the subscription locks are down to zero then notify the threads waiting
        // for the subscriptionTable lock.
        synchronized (iMutex)
        {
            // If we are exclusively locked, then just return, as long as
            // the thread that is calling is the thread that holds the
            // exclusive lock.
            if (iExclusivelyLocked && iExclusiveLockHolder == Thread.currentThread())
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "unlock");
                return;
            }

            // Decrement the lock count and notify the other threads if no
            // one holds the lock any more.
            if (--iLockCount == 0)
                notifyAll();

            if (iLockCount < 0)
            {
            	if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Unlock caused lock count to drop below zero!");
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "unlock");
                throw new SevereMessageStoreException("Unlock caused lock count to drop below zero!");
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "unlock");
    }
101973
@Override
  public void onThreadBegin()
  {
    _threadCount.incrementAndGet();
    
    int startCount = _startingCount.decrementAndGet();

    if (startCount < 0) {
      _startingCount.set(0);
      
      new IllegalStateException().printStackTrace();
    }

    _createCountTotal.incrementAndGet();
    
    update();
  }
51522
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      if (readLockCount == 0)
      {
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
            "1:237:1.3" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
              "1:244:1.3" },
            null));
      }
      
      decrementThreadLockCount();
      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (readLockCount == 0)
        notifyAll();        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
666135
@Override
    public void run()
    {
        if (running.compareAndSet(IDLE, RUNNING))
        {
            sequenceBarrier.clearAlert();

            notifyStart();
            try
            {
                if (running.get() == RUNNING)
                {
                    processEvents();
                }
            }
            finally
            {
                notifyShutdown();
                running.set(IDLE);
            }
        }
        else
        {
            // This is a little bit of guess work.  The running state could of changed to HALTED by
            // this point.  However, Java does not have compareAndExchange which is the only way
            // to get it exactly correct.
            if (running.get() == RUNNING)
            {
                throw new IllegalStateException("Thread is already running");
            }
            else
            {
                earlyExit();
            }
        }
    }
768511
private void enterExclusiveThread() {
		// we use simple get, check, set here, rather than CAS
		// we don't need lock-style correctness, this is only a sanity-check and we thus
		// favor speed at the cost of some false negatives in this check
		Thread previous = currentThread;
		Thread thisThread = Thread.currentThread();

		if (previous == null) {
			currentThread = thisThread;
		}
		else if (previous != thisThread) {
			throw new IllegalStateException(
				"Concurrent access to KryoSerializer. Thread 1: " + thisThread.getName() +
					" , Thread 2: " + previous.getName());
		}
	}
1129793
public synchronized void lock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "lock", this);

    boolean interrupted = false;

    // Attempt to get a lock on the mutex.
    // if we fail, then that is because the lock
    // must be held exclusively.
    while (!tryLock())
      try
      {
        // Wait for 1 second then try again.
        if (tc.isDebugEnabled())
          SibTr.debug(tc, "Waiting for lock");
        wait(1000);
      }
      catch (InterruptedException e)
      {
        // No FFDC code needed
        interrupted = true;
      }

    if (interrupted)
      Thread.currentThread().interrupt();

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "lock");

  }
1005969
@Override
  public void run() {
    try {
      startCleanupThreads();
      try {
        while (running && !shuttingDown) {
          try {
            heartbeatToClusterManager();
          } catch (IOException e) {
            LOG.error("Error initializing heartbeat to Cluster Manager", e);
            try {
              Thread.sleep(5000L);
            } catch (InterruptedException ie) {
            }
          }
          if (shuttingDown) {
            return;
          }
        }
      } finally {
        shutdown();
      }
    } catch (IOException iex) {
      LOG.error("Got fatal exception while initializing TaskTracker", iex);
      return;
    }
  }
87761
public void lock() {
		if (cancel != null)
			return;
		if (error != null)
			return;
		Thread t;
		BlockedThreadHandler blockedHandler;
		do {
			synchronized (this) {
				if (!locked) {
					locked = true;
					return;
				}
				t = Thread.currentThread();
				blockedHandler = Threading.getBlockedThreadHandler(t);
				if (blockedHandler != null) break;
				try { this.wait(0); }
				catch (InterruptedException e) { continue; }
			}
		} while (true);
		blockedHandler.blocked(this, 0);
	}
1335262
def keep_alive(self):
        
        self._lock.acquire()
        try:
            return len(self._deferred)
        finally:
            self._lock.release()
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;
    }