Which of the following statements are true about Java Threads?
Statement 1: In Java, normal thread priority is 1
Statement 2: In Java, thread priority ranges from 1 to 10
Statement 3: If a thread calls sleep() method, another thread will be picked up for execution,
Answers
Answer:
Statement 2: In Java, thread priority ranges from 1 to 10
Explanation:
Each thread have a priority. Priorities are represented by a number between 1 and 10
Statement 1: False. In Java, normal thread priority is 5, not 1. Thread priorities in Java range from 1 to 10 with 1 being the lowest priority and 10 being the highest. The default priority for a thread is normal priority which is set to 5.
Statement 2: True. In Java, thread priority ranges from 1 to 10. The larger the integer value of a thread’s priority, the higher its priority. The thread scheduler uses this integer value to determine which thread should be allowed to execute.
Statement 3: True. If a thread calls sleep() method, it pauses its execution temporarily and another thread may be picked up for execution. The sleep() method is a static method in the java.lang.Thread class and it is used to temporarily halt the execution of the current thread for a specified amount of time.
To learn more about Java from the given link.
https://brainly.in/question/15262300
#SPJ3