001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) 2008-2018 FIRST. 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 * Get the thread priority for the current thread. 015 * @return The current thread priority. Scaled 1-99. 016 */ 017 public static int getCurrentThreadPriority() { 018 return ThreadsJNI.getCurrentThreadPriority(); 019 } 020 021 /** 022 * Get if the current thread is realtime. 023 * @return If the current thread is realtime 024 */ 025 public static boolean getCurrentThreadIsRealTime() { 026 return ThreadsJNI.getCurrentThreadIsRealTime(); 027 } 028 029 /** 030 * Sets the thread priority for the current thread. 031 * 032 * @param realTime Set to true to set a realtime priority, false for standard 033 * priority 034 * @param priority Priority to set the thread to. Scaled 1-99, with 1 being 035 * highest. On RoboRIO, priority is ignored for non realtime setting 036 * 037 * @return The success state of setting the priority 038 */ 039 public static boolean setCurrentThreadPriority(boolean realTime, int priority) { 040 return ThreadsJNI.setCurrentThreadPriority(realTime, priority); 041 } 042}