Originally posted by Kaydell Leavitt:
If I have a thread with a priority of 10 and another with a priority of only 1, is it possible for the thread with the highest priority to dominate to the point that the thread with the lower priority isn't even called.
Definitely can, only
testing will give meaningful answers. For:
Originally posted by praveen balaji
but someone should be able to point you to a good book.
That book is defintely
Java Threads, 3rd Edition by Scott Oaks & Henry Wong. I have lots of books, this is an exceptionally good book. Thread starvation, which is the question you are asking, depends on the operating system, the workload and a compiler. Generally, a Thread aware os will silently
boost the priority of a lower priority thread if it needs that thread to complete a task; but in the more general case setting a priority of ten will make that thread seem to be the entire machine as long as there is something for it to do.
Can I prevent thread starvation by leaving all threads at a normal priority of 5?
Well yes, but what is the problem you are trying to make an approach to ?
As for sleep() v yield() - I asked about that and use the sleep(0) syntax but I was told that yield() is implemented in the Java Engine, therefore it would be a personal preference which one to use.
[ December 17, 2006: Message edited by: Nicholas Jordan ]