Vinod James wrote:Thanks for the quick replies Jesper and Tim.
How can one write a Threaded program without priorities?
If my application has like 6-7 threads, I will definitely have some threads which need to be work horses and doing more work than other threads.
How can I rewrite my application so that I am not dependent on the scheduler?
In this case then it looks like a trade off between portability and priority. Is that correct?
In my opinion, it is perfectly fine to use thread priorities (if you need to). You just can't rely that the scheduler will schedule it the same way on every OS platform. For example...
* With some OSes, there are less thread priority levels, so some adjacent priorites for the Java application may map to the same priority for the OS.
* With some OSes, a higher priority runnable thread is guaranteed to be running over a lower priority runnable thread -- even to the point of starving the lower priority runnable thread. With others, that have protections against thread starvation, the only guarantee is that the higher priority runnable thread will get more CPU cycles than the lower priority thread.
So... no strong guarantees or fine grain control, but should be fine for most intents and purposes.
Henry