Re: How to run tasks with priority?
- From: "Boudewijn Dijkstra" <usenet@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 3 Jun 2005 18:33:23 +0200
"George George via JavaKB.com" <forum@xxxxxxxxxx> schreef in bericht
news:1b0ed44698de4e4fb399a8187c1e13e0@xxxxxxxxxxxxx
> Thanks Boudewijn,
>
>
> Your sample is very helpful. But I think there is an issue in your sample,
> which is that we must hardcode the number of sections that a code block
> will be divided into. For example, in your sample, you hardcoded that Task1
> is divided into 3 sections. I am wondering whether there are any approaches
> 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--;
}
}
> 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.
> Should we do it in this approach (yield)
> manually or simply let JVM to do this.
That is a decision that I cannot make for you. ;)
.
- Follow-Ups:
- Re: How to run tasks with priority?
- From: blmblm
- Re: How to run tasks with priority?
- From: George George via JavaKB.com
- 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?
- Prev by Date: Re: Application path
- Next by Date: Re: "Could not find a valid Java virtual machine"
- Previous by thread: Re: How to run tasks with priority?
- Next by thread: Re: How to run tasks with priority?
- Index(es):
Relevant Pages
|