Threads run method that increments the clock and resets the generated
nano seconds counter.
510436
public void run() {
        try {
            while (--expires >= 0) {
                sleep(sysInterval);
                synchronized (ThreadClockImpl.class) {
                    currentTimeMillis += sysInterval;
                }
            }
        } catch (InterruptedException e) {
            System.out.println("Clock thread interrupted");
        }
    }
601490
public void advanceClock(final int offset) {
    this.currentTime += offset;
    final Iterator<Alarm> iter = this.alarmList.iterator();
    while (iter.hasNext()) {
      final Alarm alarm = iter.next();
      if (alarm.getTimestamp() <= this.currentTime) {
        alarm.run();
        iter.remove();
      }
    }
  }
1173998
private void doInterruptAllWaitingThreads() {
    	//Interrupt all the threads
    	for (int i=0; i<nThreads; i++) {
    		threads[i].interrupt();
    	}
    	
    	synchronized(lock) {
    		lock.notify();
    	}
    }
266569
def update(self):
        """"""
        if self.input_method == 'local':
            # Only refresh:
            # * if there is not other scanning thread
            # * every refresh seconds (define in the configuration file)
            if self._thread is None:
                thread_is_running = False
            else:
                thread_is_running = self._thread.isAlive()
            if self.timer_ports.finished() and not thread_is_running:
                # Run ports scanner
                self._thread = ThreadScanner(self.stats)
                self._thread.start()
                # Restart timer
                if len(self.stats) > 0:
                    self.timer_ports = Timer(self.stats[0]['refresh'])
                else:
                    self.timer_ports = Timer(0)
        else:
            # Not available in SNMP mode
            pass

        return self.stats
1126678
@Override
	public void run() {
		Stopwatch stopwatch = SimonManager.getStopwatch(NAME);
		try (Split ignored = stopwatch.start();) {
			sleep(SLEEP);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		// signal to latch that the thread is finished
		latch.countDown();
	}
76865
public void reset() {
    lastReset = new Date();

    if (counters != null) {
      synchronized (counters) {
        counters.clear();
      }
    }

    if (chronos != null) {
      synchronized (chronos) {
        chronos.clear();
      }
    }

    if (stats != null) {
      synchronized (stats) {
        stats.clear();
      }
    }
  }
694613
private void incrementCurrentValue() {
    currentValues[currentValues.length - 1]++;
    int i = currentValues.length - 1;
    while (i > 0 &&
        currentValues[i] > finalValues[i]) {
      currentValues[i] = 0;
      currentValues[i - 1]++;
      i--;
    }
  }
132543
@Override
    public void run()
    {
        if (!running.compareAndSet(false, true))
        {
            throw new IllegalStateException("Thread is already running");
        }
        sequenceBarrier.clearAlert();

        notifyStart();

        boolean processedSequence = true;
        long cachedAvailableSequence = Long.MIN_VALUE;
        long nextSequence = sequence.get();
        T event = null;
        while (true)
        {
            try
            {
                // if previous sequence was processed - fetch the next sequence and set
                // that we have successfully processed the previous sequence
                // typically, this will be true
                // this prevents the sequence getting too far forward if an exception
                // is thrown from the WorkHandler
                if (processedSequence)
                {
                    processedSequence = false;
                    do
                    {
                        nextSequence = workSequence.get() + 1L;
                        sequence.set(nextSequence - 1L);
                    }
                    while (!workSequence.compareAndSet(nextSequence - 1L, nextSequence));
                }

                if (cachedAvailableSequence >= nextSequence)
                {
                    event = ringBuffer.get(nextSequence);
                    workHandler.onEvent(event);
                    processedSequence = true;
                }
                else
                {
                    cachedAvailableSequence = sequenceBarrier.waitFor(nextSequence);
                }
            }
            catch (final TimeoutException e)
            {
                notifyTimeout(sequence.get());
            }
            catch (final AlertException ex)
            {
                if (!running.get())
                {
                    break;
                }
            }
            catch (final Throwable ex)
            {
                // handle, mark as processed, unless the exception handler threw an exception
                exceptionHandler.handleEventException(ex, nextSequence, event);
                processedSequence = true;
            }
        }

        notifyShutdown();

        running.set(false);
    }
840841
@Override
	public void run()
	{
		try {
			while (true) {
				final long start = System.currentTimeMillis();
				synchronized (lock) {
					long remaining = sweepInterval * 1000L;
					while (remaining > 0) {
						lock.wait(remaining);
						remaining = start + sweepInterval * 1000 - System.currentTimeMillis();
					}
				}
				cache.removeExpired();
			}
		}
		catch (final InterruptedException e) {
			// just let thread exit
		}
	}
816653
public void clock() {
		// No operation if test bit is set.
		if (test != 0) {
			return;
		}

		int /* reg24 */accumulator_prev = accumulator;

		// Calculate new accumulator value;
		accumulator += freq;
		accumulator &= 0xffffff;

		// Check whether the MSB is set high. This is used for synchronization.
		msb_rising = !((accumulator_prev & 0x800000) != 0)
				&& ((accumulator & 0x800000) != 0);

		// Shift noise register once for each time accumulator bit 19 is set
		// high.
		if (!((accumulator_prev & 0x080000) != 0)
				&& ((accumulator & 0x080000) != 0)) {
			int /* reg24 */bit0 = ((shift_register >> 22) ^ (shift_register >> 17)) & 0x1;
			shift_register <<= 1;
			shift_register &= 0x7fffff;
			shift_register |= bit0;
		}
	}
677940
function(factory, options) {
			factory.timer.interval = 0;
			factory.autoStart 	   = false;
			factory.running  	   = true;

			factory.increment = function() {
				factory.countdown = false;
				factory.setTime(factory.getTime().time + 1);
			};

			factory.decrement = function() {
				factory.countdown = true;
				factory.setTime(factory.getTime().time - 1);
			};

			factory.setValue = function(digits) {
				factory.setTime(digits);
			};

			factory.setCounter = function(digits) {
				factory.setTime(digits);
			};

			this.base(factory, options);
		}
75852
def _start_auto_refresh_thread(self):
        
        def run():
            while True:
                time.sleep(self.status_interval)
                self.invalidate()

        t = threading.Thread(target=run)
        t.daemon = True
        t.start()
120028
public void reset ()
    {
        if (_calibrateInterval != null) {
            _calibrateInterval.cancel();
            _calibrateInterval = null;
        }
        _startStamp = _priorCurrent = current();
        _driftMilliStamp = System.currentTimeMillis();
        _driftTimerStamp = current();
        _calibrateInterval = new Interval(Interval.RUN_DIRECT) {
            @Override public void expired () {
                calibrate();
            }
        };
        _calibrateInterval.schedule(CALIBRATE_INTERVAL, CALIBRATE_INTERVAL, false);
    }
752824
public void lock() {
        Thread t = Thread.currentThread();
        if (t == owner.get()) { // if re-enter, increment the count.
            count++;
            return;
        }
        while (owner.compareAndSet(null, t)) {
        } //spin
    }
1336559
void resetSequential() {
        seq = nextLong(prand, maxSeq);
        inc = minInc + nextLong(prand, maxInc - minInc);
    }
877587
public function resetTimer()
    {
        if (empty($this->timer) === true) {
            $this->timer = time() + $this->maxRuntime;
        }
    }
1195647
def start(self):
		
		if not hasattr(self,"thread") or not self.thread.isAlive():
			self.thread = threading.Thread(target=self.__run)
			self.status = RUNNING
			self.reset()
			self.thread.start()
		else:
			print("Clock already running!")