So, I am building an application(for machine simulator). It consists of 8 threads.Out of which one thread represents main machine. I want this thread to run for maximum time i.e. maximum CPU time should be given to this thread by thread scheduler. If I put this thread to sleep it should have very less waiting time. One of the way to achieve this would to dedicate a processor core to this thread but thread affinity can not be set in JAVA. The only option I see for doing this is to set this thread's priority to MAXIMUM. is there any other way to achieve this?
Asked
Active
Viewed 67 times
1
-
Keep using priority imo – Leo Mar 08 '14 at 04:42
-
http://stackoverflow.com/questions/2238272/java-thread-affinity – Germann Arlington Mar 08 '14 at 12:33
1 Answers
0
Use Thread.setPriority() to set the priority of your main thread to Thread.MAX_PRIORITY and set the others to Thread.MIN_PRIORITY;

user3390929
- 68
- 4