 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ian L Guest
|
Posted: Sat Oct 09, 2004 1:16 am Post subject: Thread Priorities - Only for JVM? |
|
|
I'm rather new to Java (6 months - is that new?) so a few things I'm
still rather unsure with. I'd be writing a program that would run in
the background, so I'd like to keep it low in priority. Here's the part
I'm confused: Does setting the thread's priority affect the JVM or the
whole CPU? Thanks for any help.
|
|
| Back to top |
|
 |
David Guest
|
Posted: Sat Oct 09, 2004 7:21 am Post subject: Re: Thread Priorities - Only for JVM? |
|
|
On 8 Oct 2004 18:16:50 -0700, "Ian L" <ianleow7 (AT) gmail (DOT) com> wrote:
| Quote: | I'm confused: Does setting the thread's priority affect the JVM or the
whole CPU?
|
It affects the amount of CPU that thread uses in the VM. Does that
help?
|
|
| Back to top |
|
 |
Ian L Guest
|
Posted: Tue Oct 12, 2004 3:20 am Post subject: Re: Thread Priorities - Only for JVM? |
|
|
So in other words, if I have a different program running (let's say
it's written in C++) together with a low priority Java thread, the
program (C++) will be executed first, right? I kind of get you, but not
completely. Thanks.
|
|
| Back to top |
|
 |
Ian L Guest
|
Posted: Wed Oct 13, 2004 4:11 am Post subject: Re: Thread Priorities - Only for JVM? |
|
|
In other words, if I have a high priority program not written in Java
(let's say C++) and it's running with a low priority Java thread, the
C++ program will be exectued first, right? I kind of get what you mean,
but I just need to confirm. Thanks. (This may be my second reply
because the first one didn't get posted on the web at the time of this
reply.)
|
|
| Back to top |
|
 |
Mark Bottomley Guest
|
Posted: Wed Oct 13, 2004 11:28 am Post subject: Re: Thread Priorities - Only for JVM? |
|
|
"Ian L" <ianleow7 (AT) gmail (DOT) com> wrote
| Quote: | In other words, if I have a high priority program not written in Java
(let's say C++) and it's running with a low priority Java thread, the
C++ program will be exectued first, right? I kind of get what you mean,
but I just need to confirm. Thanks. (This may be my second reply
because the first one didn't get posted on the web at the time of this
reply.)
|
Ian:
You can not compare what will happen outside a Java program to what will
happen inside. There are far too many variables. This all depends on the
scheduling algorithm used by the OS and the threading implementation used by
the JVM. The Java that launched the low priority thread was probably
launched with whatever OS default priority so it may share equally with the
C++ program and only use the priorities to decide which Java thread (and
there's only one of interest here) gets the JVM time slice from the OS. It
could also have spawned the Java thread as a separate OS thread so then the
question is about the OS support of priorities and how they map to Java
priorities (# of OS priorities >= # of Java priorities?). Also, getting to
execute first is not guaranteed as the priority implementation may not be
who goes first, but may be implemented as a maximum amount of time thay may
use before being pre-empted (if the OS supports pre-emption). Without full
knowledge of the scheduling algorithm used, you cannot guarantee anything -
and certainly not when you change platforms (e.g.
Windows->Linux->Symbian->Neutrino->....)
Mark...
|
|
| Back to top |
|
 |
Ian L Guest
|
Posted: Sat Oct 16, 2004 5:12 am Post subject: Re: Thread Priorities - Only for JVM? |
|
|
Oh, okay, I get it now. Thanks Mark!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|