I have a Java-process that I would like to run a with background priority in Windows (see here). Is there any easy way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Java does not MANDATE any implementation of threading, so the Sun JVM on Windows will work differently to the Sun JVM on Linux, etc. The Windows threading model is very different to Linux threading model. There’s nothing even to mandate that a Java thread maps to an underlying OS thread. There isn’t (or wasn’t when I looked a year ago), any documentation how the JVM implements threading on WINDOWS.
However, in your Windows-specific case, you could POSSIBLY, use JNI or a COM interface to change the process/thread priority. I wouldn’t bother though, I think it would be extremely brittle and hard to test. One difficultly is getting the underlying Windows thread ID from the Java Thread object.
What is your background task monitoring/doing? Can you think about your problem differently: what is its essence? The Java concurrency API may help with alternative solutions given clear requirements.