org.apache.lucene.search

## Class TimeLimitingCollector.TimerThread

- java.lang.Object
- - java.lang.Thread
  - - org.apache.lucene.search.TimeLimitingCollector.TimerThread

- All Implemented Interfaces:
    Runnable
  Enclosing class:
    TimeLimitingCollector

      public static final class TimeLimitingCollector.TimerThread
      extends Thread

  Thread used to timeout search requests. Can be stopped completely with `stopTimer()`
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_RESOLUTION`
    `static String` | `THREAD_NAME`

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimerThread(Counter counter)`
    `TimerThread(long resolution, Counter counter)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getMilliseconds()` Get the timer value in milliseconds.
    `long` | `getResolution()` Return the timer resolution.
    `void` | `run()`
    `void` | `setResolution(long resolution)` Set the timer resolution.
    `void` | `stopTimer()` Stops the timer thread

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

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

- - ### Field Detail

    - #### THREAD_NAME

          public static final String THREAD_NAME

      See Also:
        Constant Field Values

    - #### DEFAULT_RESOLUTION

          public static final int DEFAULT_RESOLUTION

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TimerThread

          public TimerThread(long resolution,
                             Counter counter)

    - #### TimerThread

          public TimerThread(Counter counter)

  - ### Method Detail

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `Thread`

    - #### getMilliseconds

          public long getMilliseconds()

      Get the timer value in milliseconds.

    - #### stopTimer

          public void stopTimer()

      Stops the timer thread

    - #### getResolution

          public long getResolution()

      Return the timer resolution.
      See Also:
        `setResolution(long)`

    - #### setResolution

          public void setResolution(long resolution)

      Set the timer resolution. The default timer resolution is 20 milliseconds. This means that a search required to take no longer than 800 milliseconds may be stopped after 780 to 820 milliseconds.
      Note that:
      - Finer (smaller) resolution is more accurate but less efficient.
      - Setting resolution to less than 5 milliseconds will be silently modified to 5 milliseconds.
      - Setting resolution smaller than current resolution might take effect only after current resolution. (Assume current resolution of 20 milliseconds is modified to 5 milliseconds, then it can take up to 20 milliseconds for the change to have effect.

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.