1

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?

Anand
  • 1,335
  • 1
  • 12
  • 20

1 Answers1

0

Use Thread.setPriority() to set the priority of your main thread to Thread.MAX_PRIORITY and set the others to Thread.MIN_PRIORITY;