Package ghidra.util.timer

# Class GTimer

java.lang.Object
ghidra.util.timer.GTimer

public class GTimer extends Object
A class to schedule `Runnable`s to run after some delay, optionally repeating. This class uses a `Timer` internally to schedule work. Clients of this class are given a monitor that allows them to check on the state of the runnable, as well as to cancel the runnable.

Note: The callback will be called on the `Timer`'s thread.

See also `GhidraTimerFactory`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GTimer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static GTimerMonitor`
  `scheduleRepeatingRunnable(long delay, long period, Runnable callback)`
  Schedules a runnable for repeated execution after the specified delay.
  `static GTimerMonitor`
  `scheduleRunnable(long delay, Runnable callback)`
  Schedules a runnable for execution after the specified delay.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GTimer

    public GTimer()

- ## Method Details

  - ### scheduleRunnable

    public static GTimerMonitor scheduleRunnable(long delay, Runnable callback)
    Schedules a runnable for execution after the specified delay. A delay value less than 0 will cause this timer to schedule nothing. This allows clients to use this timer class with no added logic for managing timer enablement.
    Parameters:
      `delay` - the time (in milliseconds) to wait before executing the runnable. A negative value signals not to run the timer--the callback will not be executed
      `callback` - the runnable to be executed.
    Returns:
      a GTimerMonitor which allows the caller to cancel the timer and check its status.

  - ### scheduleRepeatingRunnable

    public static GTimerMonitor scheduleRepeatingRunnable(long delay, long period, Runnable callback)
    Schedules a runnable for repeated execution after the specified delay. A delay value less than 0 will cause this timer to schedule nothing. This allows clients to use this timer class with no added logic for managing timer enablement.
    Parameters:
      `delay` - the time (in milliseconds) to wait before executing the runnable. A negative value signals not to run the timer--the callback will not be executed
      `period` - time in milliseconds between successive runnable executions
      `callback` - the runnable to be executed
    Returns:
      a GTimerMonitor which allows the caller to cancel the timer and check its status
    Throws:
      `IllegalArgumentException` - if `period <= 0`