Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this
point.

@return this {@code Stopwatch} instance
@throws IllegalStateException if the stopwatch is already stopped.
778668
public Stopwatch stop() {
    long tick = ticker.read();
    checkState(isRunning, "This stopwatch is already stopped.");
    isRunning = false;
    elapsedNanos += tick - startTick;
    return this;
  }
759302
public synchronized long stop() {

		stopTime = System.currentTimeMillis();
		currentTime = stopTime - startTime;
		started = false;

		return currentTime;
	}
878203
@Override
	public CompletableFuture<Void> onStop() {
		log.info("Stopping TaskExecutor {}.", getAddress());

		Throwable throwable = null;

		if (resourceManagerConnection != null) {
			resourceManagerConnection.close();
		}

		for (JobManagerConnection jobManagerConnection : jobManagerConnections.values()) {
			try {
				disassociateFromJobManager(jobManagerConnection, new FlinkException("The TaskExecutor is shutting down."));
			} catch (Throwable t) {
				throwable = ExceptionUtils.firstOrSuppressed(t, throwable);
			}
		}

		jobManagerHeartbeatManager.stop();

		resourceManagerHeartbeatManager.stop();

		try {
			stopTaskExecutorServices();
		} catch (Exception e) {
			throwable = ExceptionUtils.firstOrSuppressed(e, throwable);
		}

		if (throwable != null) {
			return FutureUtils.completedExceptionally(new FlinkException("Error while shutting the TaskExecutor down.", throwable));
		} else {
			log.info("Stopped TaskExecutor {}.", getAddress());
			return CompletableFuture.completedFuture(null);
		}
	}
360598
public Stopwatch start() {
        if (myTimerIsRunning) {
            throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_040));
        }

        myStart = System.currentTimeMillis();
        myTimerIsRunning = true;

        return this;
    }
1255607
public Stopwatch stopAfter(final int aSecondsCount) {
        if (!myTimerIsRunning) {
            throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_041));
        }

        int stopCount = aSecondsCount;

        while (stopCount < aSecondsCount) {
            stopCount = (int) (System.currentTimeMillis() - myStart) / 1000;
        }

        myStop = System.currentTimeMillis();
        myTimerIsRunning = false;

        return this;
    }
405696
public static void stopService() {
        DaemonStarter.currentPhase.set(LifecyclePhase.STOPPING);
        final CountDownLatch cdl = new CountDownLatch(1);
        Executors.newSingleThreadExecutor().execute(() -> {
            DaemonStarter.getLifecycleListener().stopping();
            DaemonStarter.daemon.stop();
            cdl.countDown();
        });

        try {
            int timeout = DaemonStarter.lifecycleListener.get().getShutdownTimeoutSeconds();
            if (!cdl.await(timeout, TimeUnit.SECONDS)) {
                DaemonStarter.rlog.error("Failed to stop gracefully");
                DaemonStarter.abortSystem();
            }
        } catch (InterruptedException e) {
            DaemonStarter.rlog.error("Failure awaiting stop", e);
            Thread.currentThread().interrupt();
        }

    }
630500
@Write(consumes = {})
    public Object stop() {
        try {
            return message;
        } finally {
            Thread thread = new Thread(this::stopServer);
            thread.setContextClassLoader(getClass().getClassLoader());
            thread.start();
        }
    }
362042
public void stop() {
    syncLock.lock();
    try {
      if (syncThread == null) {
        return;
      }
      instanceChangeStreamListener.stop();
      syncThread.interrupt();
      try {
        syncThread.join();
      } catch (final InterruptedException e) {
        return;
      }
      syncThread = null;
      isRunning = false;
    } finally {
      syncLock.unlock();
    }
  }
449058
public void stop() {
        if (tape == null) {
            throw new IllegalStateException("stop called when Recorder is not started");
        }

        for (RecorderListener listener : listeners) {
            listener.onRecorderStop();
        }
        getTapeLoader().writeTape(tape);
        tape = null;
    }
953002
@Override
  public void close() {
    stopWatch.stop();

    if (logger.isLoggable(logLevel)) {
      final StringBuilder sb = new StringBuilder();
      log(sb.append(EXIT_PREFIX).append(msg).append(DURATION).append(stopWatch.getTime()).toString());
    }
  }
923632
public StopWatch tick() {
        long old = ticker;
        ticker = System.currentTimeMillis();
        lastElapsed = (int) (ticker - old);
        return this;
    }
604214
@Override
  public void stop(final Throwable exception) {

    LOG.entering(CLASS_NAME, "stop");

    synchronized (this.schedule) {

      if (this.isClosed) {
        LOG.log(Level.FINEST, "Clock has already been closed");
        return;
      }

      this.isClosed = true;
      this.exceptionCausedStop = exception;

      final Time stopEvent = new StopTime(this.timer.getCurrent());
      LOG.log(Level.FINE,
          "Stop scheduled immediately: {0} Outstanding client alarms: {1}",
          new Object[] {stopEvent, this.numClientAlarms});

      assert this.numClientAlarms >= 0;
      this.numClientAlarms = 0;

      this.schedule.clear();
      this.schedule.add(stopEvent);
      this.schedule.notify();
    }

    LOG.exiting(CLASS_NAME, "stop");
  }
943700
public MockServerClient stop(boolean ignoreFailure) {
        MockServerEventBus.getInstance().publish(EventType.STOP);
        try {
            sendRequest(request().withMethod("PUT").withPath(calculatePath("stop")));
            if (isRunning()) {
                for (int i = 0; isRunning() && i < 50; i++) {
                    TimeUnit.MILLISECONDS.sleep(5);
                }
            }
        } catch (RejectedExecutionException ree) {
            mockServerLogger.trace("Request rejected because closing down but logging at trace level for information just in case due to some other actual error " + ree);
        } catch (Exception e) {
            if (!ignoreFailure) {
                mockServerLogger.warn("Failed to send stop request to MockServer " + e.getMessage());
            }
        }
        if (!eventLoopGroup.isShuttingDown()) {
            eventLoopGroup.shutdownGracefully();
        }
        return clientClass.cast(this);
    }
756038
public Stopwatch start() {
    Assert.isTrue(!isRunning);
    isRunning = true;
    startTick = ticker.read();
    return this;
  }
442281
public boolean waitForNewTimeslot() throws InterruptedException {
		
		boolean hasWaited = false;
		
		while(true) {
			final long numberOfEventsInTimeSlot = getNumberOfEventsInTimeslot();
			
			if(numberOfEventsInTimeSlot > numberOfEvents) {
				hasWaited = true;
				Thread.sleep(timeslotInMilliseconds / 10);
			} else {
				return hasWaited;
			}
		}
	}
321370
public static Stopwatch create(VoidCallable callable) {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.callable = callable;
        return stopwatch;
    }
379507
public void stop() {
    ScheduledExecutorService service = executor.get();
    if (service != null && executor.compareAndSet(service, null)) {
      service.shutdown();
    } else {
      throw new IllegalStateException("scheduler must be started before you stop it");
    }
  }