Re: How to run tasks with priority?



"George George via JavaKB.com" <forum@xxxxxxxxxx> schreef in bericht
news:00c78c327e394403907c1ce6b436fdd1@xxxxxxxxxxxxx
> Thanks Boudewijn,
>
> Your reply is very helpful! I found that if I use priority feature of Java
> thread, then I can only have (MAX_PRIORITY - MIN_PRIORITY) different
> priorities, which may limit my application. I am wondering whether there
> are any alternate solutions which may have more different priorities.

It sounds like you need to use synchronization, not priorities. With
synchronized{} blocks you can make threads wait for eachother at fixed points.

>> You can accomplish this behaviour with the Thread#yield
>> () method.
>
> How can I utilize utilize yield? Could you please give me a simple sample?

If two threads have the same priority and execute the same code, adding a
yield call to one of those, could make it run about twice as slow.


.



Relevant Pages

  • Re: How to run tasks with priority?
    ... I found that if I use priority feature of Java ... are any alternate solutions which may have more different priorities. ... How can I utilize utilize yield? ...
    (comp.lang.java.help)
  • Re: Software suggestions
    ... Java enthusiasts seem to believe that it's closing the speed gap, but I tend to agree that C/C++ produces faster running programs. ... You're right that academics have different priorities. ... Java is more buttoned-down than C++, which allows the compiler to spot errors on my part that a C++ compiler would consider valid code. ...
    (comp.constraints)