Re: How to run tasks with priority?
- From: "George George via JavaKB.com" <forum@xxxxxxxxxx>
- Date: Sat, 04 Jun 2005 13:21:42 GMT
Thanks Boudewijn,
Boudewijn Dijkstra wrote:
>> Thanks Boudewijn,
>>
>[quoted text clipped - 4 lines]
>> which can flexibly define the number of sections in which a thread will be
>> divided into.
>
>You don't actually have to define your code into sections. It should even be
>possible to change the number of synchronized accesses dynamically, by using a
>loop inside your main loop:
>
>for (int i = syncCount; i >= 0; ) {
> synchronized (lock) {
> i--;
> }
>}
Do you mean that when the current thread leaves a synchronized block, it
will release the lock and then other threads will have chances to obtain
the lock?
>> Are there any practical uses that we should give away it's cycle to other
>> threads with the same priority?
>
>Yes. You can use it in a lot of cases when you're using the sleep method, but
>without the chance of actually idleing the CPU.
Do you mean using yield method will idle the CPU? If it is true, do you
know how to write a simple program to test that sleep method will not idle
CPU, and at the same time yield method will idle CPU?
Have a nice weekend,
George
--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200506/1
.
- Follow-Ups:
- Re: How to run tasks with priority?
- From: Boudewijn Dijkstra
- Re: How to run tasks with priority?
- References:
- Re: How to run tasks with priority?
- From: George George via JavaKB.com
- Re: How to run tasks with priority?
- From: Boudewijn Dijkstra
- Re: How to run tasks with priority?
- From: George George via JavaKB.com
- Re: How to run tasks with priority?
- From: Boudewijn Dijkstra
- Re: How to run tasks with priority?
- From: George George via JavaKB.com
- Re: How to run tasks with priority?
- From: Boudewijn Dijkstra
- Re: How to run tasks with priority?
- Prev by Date: Tools/simulators for SMS message testing
- Next by Date: design critique
- Previous by thread: Re: How to run tasks with priority?
- Next by thread: Re: How to run tasks with priority?
- Index(es):
Relevant Pages
|