Re: How to run tasks with priority?
- From: "Boudewijn Dijkstra" <usenet@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 18:01:19 +0200
"George George via JavaKB.com" <forum@xxxxxxxxxx> schreef in bericht
news:9172182393fd41b8bb4668184d84de95@xxxxxxxxxxxxx
>>
>>The API documentation description of yield() is a bit cumbersome. But it is
>>enough for those who are educated in the most important concepts of task
>>scheduling. Sensing that you are not, I will explain what happens when
>>yield() is called.
>>
>>1. The current thread is paused, but remains ready to run.
>>2. The task scheduler checks the current priority queue for threads (other
>>than the current one) that are ready to run.
>>3a. If there are, then perform a task-switch to the first one.
>>3b. If there aren't, then un-pause the current thread.
>>
>>Note that, although the current thread is suspended, the CPU always has
>>something to run during steps 1,2,3.
>
> Your description is very helpful and it has answered my question.
Thanks.
> Do you
> know whether there exists a tool which can monitor what threads are running
> on a VM and how much running time they have allocated from VM, just like
> the performance monitor of task manager of Windows XP (invoked from "My
> Computer")? If there exists such a tool in Java, it will make our work very
> convenient, isn't it? :-)
Such a tool is called a profiler. I've never used one, so I don't know which
one you should get.
>>> Another small issue is that, why you use join method in your getFinalScore
>>> method? I have not seen its special functons yet.
>>
>>When 'running' is set to false, the thread does not immediately exit. By
>>calling join(), the thread that executes getFinalScore() waits for it to
>>exit >>so that it can fetch the *final* score.
>
> Your idea of using join is very intelligent!
Alas, it wasn't my idea. It is actually a very common pattern, and according
to some people, THE pattern.
.
- Follow-Ups:
- 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?
- 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?
- 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?
- From: George George via JavaKB.com
- Re: How to run tasks with priority?
- Prev by Date: policy file
- Next by Date: Re: policy file
- Previous by thread: Re: How to run tasks with priority?
- Next by thread: Re: How to run tasks with priority?
- Index(es):