Venkat Reddy
Venkat Reddy

Reputation: 1

Can we change priority of a thread while thread is in execution.Will the change takes place or the os ignores it?(Java)

I am writing a program where all threads will be in execution and In middle of the execution I should be able to change priority and this change should take place immediately.(I have changed lower priority thread to higher)and next higher should execute first.Will this work

Upvotes: 0

Views: 128

Answers (1)

kishor borate
kishor borate

Reputation: 156

Java provides no guarantee that high priority thread will get executed before low priority. High priority thread will get more of a CPU time, but that doesn't mean the low priority thread will wait until the high priority thread is finished. To summarize, the order of execution of threads will be random, regardless of priority.

Upvotes: 1

Related Questions