001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */ 003/* Open Source Software - may be modified and shared by FRC teams. The code */ 004/* must be accompanied by the FIRST BSD license file in the root directory of */ 005/* the project. */ 006/*----------------------------------------------------------------------------*/ 007 008package edu.wpi.first.wpilibj; 009 010import edu.wpi.first.wpilibj.hal.ThreadsJNI; 011 012public class Threads { 013 014 /** 015 * Get the thread priority for the current thread. 016 * @return The current thread priority. Scaled 1-99. 017 */ 018 public static int getCurrentThreadPriority() { 019 return ThreadsJNI.getCurrentThreadPriority(); 020 } 021 022 /** 023 * Get if the current thread is realtime. 024 * @return If the current thread is realtime 025 */ 026 public static boolean getCurrentThreadIsRealTime() { 027 return ThreadsJNI.getCurrentThreadIsRealTime(); 028 } 029 030 /** 031 * Sets the thread priority for the current thread. 032 * 033 * @param realTime Set to true to set a realtime priority, false for standard 034 * priority 035 * @param priority Priority to set the thread to. Scaled 1-99, with 1 being 036 * highest. On RoboRIO, priority is ignored for non realtime setting 037 * 038 * @return The success state of setting the priority 039 */ 040 public static boolean setCurrentThreadPriority(boolean realTime, int priority) { 041 return ThreadsJNI.setCurrentThreadPriority(realTime, priority); 042 } 043}