Starts the timer. This method is called when {@link #acquire()} is called
for the first time. It schedules a task to be executed at fixed rate to
monitor the time period specified.

@return a future object representing the task scheduled
555772
protected ScheduledFuture<?> startTimer() {
        return getExecutorService().scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                endOfPeriod();
            }
        }, getPeriod(), getPeriod(), getUnit());
    }
516646
public int start()
    {
        int rc = 0;

        timers.addAll(newTimers);
        newTimers.clear();

        //  Recalculate all timers now
        for (STimer timer : timers) {
            timer.when = timer.delay + System.currentTimeMillis();
        }

        //  Main reactor loop
        while (!Thread.currentThread().isInterrupted()) {
            if (dirty) {
                // If s_rebuild_pollset() fails, break out of the loop and
                // return its error
                rebuild();
            }
            long wait = ticklessTimer();

            rc = pollset.poll(wait);

            if (rc == -1) {
                if (verbose) {
                    System.out.printf("I: zloop: interrupted (%d)\n", rc);
                }
                rc = 0;
                break; //  Context has been shut down
            }
            //  Handle any timers that have now expired
            Iterator<STimer> it = timers.iterator();
            while (it.hasNext()) {
                STimer timer = it.next();
                if (System.currentTimeMillis() >= timer.when && timer.when != -1) {
                    if (verbose) {
                        System.out.println("I: zloop: call timer handler");
                    }
                    rc = timer.handler.handle(this, null, timer.arg);
                    if (rc == -1) {
                        break; //  Timer handler signaled break
                    }
                    if (timer.times != 0 && --timer.times == 0) {
                        it.remove();
                    }
                    else {
                        timer.when = timer.delay + System.currentTimeMillis();
                    }
                }
            }
            if (rc == -1) {
                break; // Some timer signalled break from the reactor loop
            }

            //  Handle any pollers that are ready
            for (int itemNbr = 0; itemNbr < pollSize; itemNbr++) {
                SPoller poller = pollact[itemNbr];
                if (pollset.getItem(itemNbr).isError()) {
                    if (verbose) {
                        System.out.printf(
                                          "I: zloop: can't poll %s socket (%s, %s)\n",
                                          poller.item.getSocket() != null ? poller.item.getSocket().getType() : "RAW",
                                                  poller.item.getSocket(),
                                                  poller.item.getRawSocket());
                    }
                    //  Give handler one chance to handle error, then kill
                    //  poller because it'll disrupt the reactor otherwise.
                    if (poller.errors++ > 0) {
                        removePoller(poller.item);
                    }
                }
                else {
                    poller.errors = 0; //  A non-error happened
                }

                if (pollset.getItem(itemNbr).readyOps() > 0) {
                    if (verbose) {
                        System.out.printf(
                                          "I: zloop: call %s socket handler (%s, %s)\n",
                                          poller.item.getSocket() != null ? poller.item.getSocket().getType() : "RAW",
                                                  poller.item.getSocket(),
                                                  poller.item.getRawSocket());
                    }
                    rc = poller.handler.handle(this, poller.item, poller.arg);
                    if (rc == -1) {
                        break; //  Poller handler signaled break
                    }
                }
            }

            //  Now handle any timer zombies
            //  This is going to be slow if we have many zombies
            for (Object arg : zombies) {
                it = timers.iterator();
                while (it.hasNext()) {
                    STimer timer = it.next();
                    if (timer.arg == arg) {
                        it.remove();
                    }
                }
            }
            //  Now handle any new timers added inside the loop
            timers.addAll(newTimers);
            newTimers.clear();

            if (rc == -1) {
                break;
            }
        }

        return rc;
    }
1159953
public void start() throws Exception
    {
        Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");

        task = executor.scheduleWithFixedDelay
        (
            new Runnable()
            {
                @Override
                public void run()
                {
                    doWork();
                }
            },
            reapingThresholdMs,
            reapingThresholdMs,
            TimeUnit.MILLISECONDS
        );
        if (leaderLatch != null)
        {
            leaderLatch.start();
        }
        reaper.start();
    }
1025122
public void start() {

		// Basic properties
		this.logger.info( "Agent '" + getAgentId() + "' is about to be launched." );
		if( Utils.isEmptyOrWhitespaces( this.ipAddress )) {
			this.ipAddress = AgentUtils.findIpAddress( this.networkInterface );
			this.logger.info( "IP address resolved to " + this.ipAddress );
		}

		// Create a messaging client
		this.messagingClient = newReconfigurableClientAgent();
		this.messagingClient.setDomain( this.domain );
		AgentMessageProcessor messageProcessor = newMessageProcessor();
		this.messagingClient.associateMessageProcessor( messageProcessor );

		// Deal with dynamic parameters
		reloadUserData();
		reconfigure();

		// Prepare the timer for scheduled tasks
		TimerTask timerTask = new HeartbeatTask( this );
		this.heartBeatTimer = new Timer( "Roboconf's Heartbeat Timer @ Agent", true );
		this.heartBeatTimer.scheduleAtFixedRate( timerTask, Constants.HEARTBEAT_PERIOD, Constants.HEARTBEAT_PERIOD );

		this.logger.info( "Agent '" + getAgentId() + "' was launched." );
	}
1370675
void start( ScheduledExecutorService service ) {
        if (rollupFuture.get() != null) {
            // already started ...
            return;
        }

        // Pre-populate the metrics (overwriting any existing history object) ...
        durations.put(DurationMetric.QUERY_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS,
                                                                               MAXIMUM_LONG_RUNNING_QUERY_COUNT));
        durations.put(DurationMetric.SEQUENCER_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS,
                                                                                   MAXIMUM_LONG_RUNNING_SEQUENCING_COUNT));
        durations.put(DurationMetric.SESSION_LIFETIME, new DurationHistory(TimeUnit.MILLISECONDS,
                                                                           MAXIMUM_LONG_RUNNING_SESSION_COUNT));

        for (ValueMetric metric : EnumSet.allOf(ValueMetric.class)) {
            boolean resetUponRollup = !metric.isContinuous();
            values.put(metric, new ValueHistory(resetUponRollup));
        }

        // Initialize the start times in a threadsafe manner ...
        DateTime now = timeFactory.create();
        this.weeksStartTime.compareAndSet(null, now);
        this.daysStartTime.compareAndSet(null, now);
        this.hoursStartTime.compareAndSet(null, now);
        this.minutesStartTime.compareAndSet(null, now);
        this.secondsStartTime.compareAndSet(null, now);
        rollup();

        // Then schedule the rollup to be done at a fixed rate ...
        this.rollupFuture.set(service.scheduleAtFixedRate(new Runnable() {
            @SuppressWarnings( "synthetic-access" )
            @Override
            public void run() {
                rollup();
            }
        }, CAPTURE_DELAY_IN_SECONDS, CAPTURE_INTERVAL_IN_SECONDS, TimeUnit.SECONDS));
    }
1291247
public TimerTask getTimerTask()
	{
            if (logger.isLoggable(Level.FINEST)) {
                   logger.entering(CLASS_NAME, "getTimerTask")    ;
                   logger.exiting(CLASS_NAME, "getTimerTask")    ;
            }
            if (task==null)
            	task = new EntryTimer();
		return task;
	}
908426
@Nonnull
    private Timer getTimer() {
        return timerReference.updateAndGet(timer -> timer == null ? new Timer(LogConfigurationTask.class.getSimpleName(), true) : timer);
    }
564004
public synchronized void start(long period, TimeUnit timeUnit) {
		if (scheduledFuture == null) {
			PurgerRunnable runnable = new PurgerRunnable(manager);
			scheduledFuture = executorService.scheduleWithFixedDelay(runnable, period, period, timeUnit);
		} else {
			throw new IllegalStateException("IncrementSimonPurger has already been started");
		}
	}
926953
static Timer createTimer() {
		try {
			return getInstance().doPrivileged(new PrivilegedAction<Timer>() {
				@Override
				public Timer run() {
					return new Timer(true);			// 691649
				}
			});
		} catch (SecurityException se) {
			// TODO: Add logging here but be careful since this code is used in logging logic itself
			//       and may result in an indefinite loop.
			return null;
		}
	}
1130404
public void start() // F73234
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "start");

        ivScheduledFuture = ivDeferrableScheduledExecutorService.schedule(this,
                                                                          ivSweepInterval,
                                                                          TimeUnit.MILLISECONDS); // F73234

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "start");
    }
928738
public Calendar getStart() {
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(start);
		return cal;
	}
94272
public TimeCounter start() {
        switch (state) {
            case UNSTARTED:
                watch.start();
                break;
            case RUNNING:
                throw new IllegalStateException("Already started. ");
            case STOPPED:
                watch.resume();
        }
        state = State.RUNNING;
        return this;
    }
884234
def start(self):
        
        t=threading.Thread(target=self._consume)
        t.start()
415865
private synchronized void start() {
        // only reschedule if monitor is still active (not in the process of being initialized or destroyed
        // don't schedule a task if there are no monitors or the monitorInterval was set to 0
        // don't schedule a task if the framework is stopping
        if (scheduledFuture == null
            && monitorState.get() == MonitorState.ACTIVE.ordinal()
            && !updateMonitors.isEmpty()
            && monitorInterval != 0
            && FrameworkState.isValid()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(this, tc, "Scan task scheduled");
            }
            scheduledFuture = coreService.getScheduler().scheduleWithFixedDelay(this, monitorInterval, monitorInterval, monitorTimeUnit);
        }
    }
617371
def start(self):
        
        with self._lock:
            if self._running:
                return

            self._stopped = False
            self._running = True
            self._start_idle_timer()
            _logger.debug(u'starting thread of type %s to run the scheduler',
                          _THREAD_CLASS)
            self._thread = create_thread(target=self._schedule_flushes)
            try:
                self._thread.start()
            except Exception:  # pylint: disable=broad-except
                _logger.warn(
                    u'no scheduler thread, scheduler.run() will be invoked by report(...)',
                    exc_info=True)
                self._thread = None
                self._initialize_flushing()
881668
public synchronized ScheduledService start() {
        if (started) {
            return this;
        }
        if (scheduledExecutorService == null) {
            scheduledExecutorService = new ScheduledThreadPoolExecutor(1,
                new NamedThreadFactory(threadName, true));
        }
        ScheduledFuture future = null;
        switch (mode) {
            case MODE_FIXEDRATE:
                future = scheduledExecutorService.scheduleAtFixedRate(runnable, initialDelay,
                    period,
                    unit);
                break;
            case MODE_FIXEDDELAY:
                future = scheduledExecutorService.scheduleWithFixedDelay(runnable, initialDelay, period,
                    unit);
                break;
            default:
                break;
        }
        if (future != null) {
            this.future = future;
            // 缓存一下
            SCHEDULED_SERVICE_MAP.put(this, System.currentTimeMillis());
            started = true;
        } else {
            started = false;
        }
        return this;
    }
1277817
def start(self):
        """"""
        assert not self._timer, '%r is already started; to restart it, cancel it first' % self
        loop = evergreen.current.loop
        current = evergreen.current.task
        if self.seconds is None or self.seconds < 0:
            # "fake" timeout (never expires)
            self._timer = None
        elif self.exception is None or isinstance(self.exception, bool):
            # timeout that raises self
            self._timer = loop.call_later(self.seconds, self._timer_cb, current.throw, self)
        else:
            # regular timeout with user-provided exception
            self._timer = loop.call_later(self.seconds, self._timer_cb, current.throw, self.exception)