title: How to change the priority of a running java process?
body: <p>In a <a href="https://stackoverflow.com/questions/6223765/start-a-java-process-using-runtime-exec-processbuilder-start-with-low-priorit">related question</a> we explored using ProcessBuilder to start external processes in low priority using OS-dependant commands. I also discovered that if a parent process is low priority, then all of its spawned processes start in low priority. So my new question is about starting a java file (run via double-clicking an executable jar in windows) in low priority or changing its priority programmatically during the run. I have tried altering the thread priority, but this has no effect on the windows process priority.</p>
  
  <p>I have tried the following, but it does not change the process priority in the task manager</p>
  
  <pre><code>public class hello{
      public hello(){
          try{
              Thread.currentThread().setPriority(1);
              Thread.sleep(10000);    
          }catch(Exception e){e.printStackTrace();}
      }
  }
  </code></pre>
  
  <p>The only other thing I can think of is to run the program using a batch file, but I would rather keep this in the family so to speak. So does anyone know of a java-based way to change the current process priority? Ideally, it would be nice to be able to change the priority of the process in response to user input while the program is running.</p>