Re: How to run tasks with priority?



Thanks Boudewijn,


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

It is a very good idea! I am not quite familar with the technology you
mentioned. Could you please provide 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.

I am wondering why should I use yield to make one thread run slower than
another one. I think thread with equal priority should have the same chance
to run. What is your purpose of using yield?


regards,
George

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200506/1
.



Relevant Pages

  • Re: How to run tasks with priority?
    ... >> It sounds like you need to use synchronization, ... Only one thread can hold the same lock at the same time. ... private static final Object lock = LockHolder.getLock; ... I think thread with equal priority should have the same chance ...
    (comp.lang.java.help)
  • pthread_cond_signal wakes low priority thread
    ... While twiddling with priorities and synchronization i noticed something: ... if 2 threads are waiting on the same condition, one with a high and one with a low priority, the pthread_cond_signalon that condition wakes the thread that did pthread_cond_waitfirst, no matter what the priority of the thread are! ...
    (comp.programming.threads)
  • Re: Re:without message queue
    ... " It is understandable that, at some certain point, your thread has to yield ... the CPU, so that some other thread gets a chance to run". ... Your real-time priority thread voluntarily yields the CPU by entering ... Meanwhile, some other real-time priority thread starts running, and does not ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Dont really understand Thread.yield()
    ... > if a thead calls yield()? ... moved to the end of its priority ... so the new currently running thread is selected among ... If there are other threads with the same priority as the yielding ...
    (comp.lang.java.programmer)
  • Re: Resent: BUG in RT 45-01 when RT program dumps core
    ... This is a check that we have to flag when a RT task calls yield. ... So if the RT task is yielding to let a lower priority task ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)