Profile Image
vishnupriya

What is JVM startup parameter: -XX:(+|-)UseThreadPriorities?

What is JVM startup parameter: -XX:(+|-)UseThreadPriorities? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-usethreadpriorities

  • x-usethreadpriorities

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:                                                    

 

The JVM parameter “-XX:(+|-)UseThreadPriorities” allows you enable or disable the control of the priority of Java Threads APIs.

 

Since:

 

Starting from JDK 6.

 

Syntax:

  • java -XX:[+|-]UseThreadPriorities

Examples:

  • Explicitly enables use of the Java Threads API: java -XX:+UseThreadPriorities
  • Explicitly disables use of the Java Threads API: java -XX:-UseThreadPriorities

Description:

 

When working with multithreading, JVM uses a thread scheduler that has control over threads to decide which thread should run or wait and assigns a priority to it. The priority of each thread lies between 1 and 10. If a thread has a higher priority, it has more chance to get picked up by the thread scheduler. But it’s not totally guaranteed for the reason that it depends completely on JVM that chooses scheduling for the thread. The default priority is 5, the minimum is 1 and the maximum is 10.

 

The JVM parameter “UseThreadPriorities” allows you to enable or disable the use of native thread priorities. This will allows you to set a priority manually to a thread with the function java.lang.Thread.setPriority() also the use of its related APIs. If this feature is disabled, using these APIs has no effect.

 

Default Value:

 

The default value depends on the running platform.

 

Errors:

 

Throws an exception if the option is not available by the platform you are running on.

 

Related Posts:

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-usethreadpriorities

  • x-usethreadpriorities

  • JVM startup parameter