Re: How to run tasks with priority?



"George George via JavaKB.com" <forum@xxxxxxxxxxxxxxxxx> schreef in bericht
news:a4ce638f7c5543e4bb1f3c3d5e711194@xxxxxxxxxxxxx
> Hello everyone,
>
>
> I want to run tasks with priority, i.e. among several simultaneous running
> tasks, the task with the higher priority will have more chances to occupy
> CPU time. I have the following 2 issues dealing with the implementation of
> such feature.
>
> - To define each task as a thread or as a method?

It would generally be wise to allocate a thread for each task. How you define
the tasks, doesn't matter much.

> - How to change the
> priority of each task dynamically when they are running?

Thread#setPriority(int)

> - The priority feature of Java thread does not meet my requirement, since I
> can not define priority precisely. For example, I want to define that a
> task with priority A will occupy CPU time 3 times than a task with priority
> B.

You can accomplish this behaviour with the Thread#yield() method.

> I am wondering whether I can find similar open source projects or tutorials?

Similar to what?


.



Relevant Pages

  • How to run tasks with priority?
    ... I want to run tasks with priority, i.e. among several simultaneous running ... task with priority A will occupy CPU time 3 times than a task with priority ...
    (comp.lang.java.help)
  • Changing Program Process Priority Defaults
    ... changing the program priority. ... It was distributed to limit the CPU time that the SETI ... >My kids love playing a Disney Lama Game. ... >automatically force the default to normal priority? ...
    (microsoft.public.windowsxp.general)
  • Re: Windows service Vs Console app performance
    ... but priority is a funny thing. ... other open windows, task bar applets, mouse, etc. ... > can have as much CPU time as it wants, bar what is needed for the OS, so ... > Maybe he has another processor intensive task running at the same time? ...
    (microsoft.public.dotnet.framework)
  • Re: -mm seems significanty slower than mainline on kernbench
    ... If it does we probably have to wear the cost as ... At the most it changes the frequency at which load balancing occurs. ... priority tasks were balanced more frequently and ended up getting their own ... a kernbench is only about 1% of the total CPU time and the extra ...
    (Linux-Kernel)
  • Re: DirectShow Thread Priority
    ... > I'm not persuaded that it does run at a higher priority. ... other CPU-intensive tasks going on during video rendering, ... will take most of the CPU time anyway. ... difference in performance by the encoder. ...
    (microsoft.public.win32.programmer.directx.video)