What is Thread ? How to set the priority of Thread.
Answers
Answered by
18
Thread - JVM selects to run a Runnable thread with the highest priority. All Java threads have a priority in the range 1-10. Whenever a new Java thread is created it has the same priority as the thread which created it.
To set priority of Thread - :
Each Java thread is given a numeric priority between MIN_PRIORITY and MAX_PRIORITY (constants defined in the Thread class). At any given time, when multiple threads are ready to be executed, the thread with the highest priority is chosen for execution.
Hope it helps!
Similar questions
But, you can also set a thread’s priority directly by calling the setPriority() method on a Thread instance. One thing to remember about thread priorities is never rely on thread priorities, because thread-scheduling priority behavior is not guaranteed.