001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package org.wpilib.system;
006
007import org.wpilib.hardware.hal.ThreadsJNI;
008
009/** Thread utility functions. */
010public final class Threads {
011  /**
012   * Gets the current thread's priority.
013   *
014   * <p>Priorities range from 0 to 99 where 0 is non-real-time, and 1-99 are real-time, and 99 is
015   * highest priority. See "man 7 sched" for details.
016   *
017   * @return The current thread's priority.
018   */
019  public static int getCurrentThreadPriority() {
020    return ThreadsJNI.getCurrentThreadPriority();
021  }
022
023  /**
024   * Sets the current thread's priority.
025   *
026   * <p>Priorities range from 0 to 99 where 0 is non-real-time, 1-99 are real-time, and 99 is
027   * highest priority. See "man 7 sched" for details.
028   *
029   * @param priority The priority.
030   * @return True on success.
031   * @deprecated Incorrect usage of real-time priority can lead to system lockups. Only use this
032   *     function if you are trained in real-time software development.
033   */
034  @Deprecated
035  public static boolean setCurrentThreadPriority(int priority) {
036    return ThreadsJNI.setCurrentThreadPriority(priority);
037  }
038
039  private Threads() {}
040}