The starvation example in your book works different on my system (SuSe Linux 10.0). The starvation thread always runs, and in about forty trys, thread four never ran. Do you have any idea why?
It appears that my JVM runs the threads in order, almost every time, like so:
Starvation Thread: is working 10 Starvation Thread: is working 9 Starvation Thread: is working 8 Starvation Thread: is working 7 Starvation Thread: is working 6 Starvation Thread: is working 5 Starvation Thread: is working 4 Starvation Thread: is working 3 Starvation Thread: is working 2 Starvation Thread: is working 1 Thread-2: is working 10 Thread-2: is working 9 Thread-2: is working 8 Thread-2: is working 7 Thread-3: is working 10 Thread-3: is working 9 Thread-3: is working 8 Thread-3: is working 7 Thread-3: is working 6 Thread-3: is working 5 Thread-3: is working 4 Thread-3: is working 3 Thread-3: is working 2 Thread-3: is working 1
The thread priority seems to have no effect on the starvation thread.
I will have to check into this - I don't know why you are getting different results. I will check this on RedHat Linux a bit later and see what I get, and look at the Sun documentation on green threads.
Are you using Sun's JVM, or one of the other JVMs?
Regardless, I think you are still seeing the results of starvation, even if it was not the desired effect - that is, in your case, thread 4 starved.