Priority and static main

B

bigbinc

I have a threaded application that I am trying to reduce the priority
for. I have it set at the min and all my while loops are within the
thread, but under windows2000 it still runs the CPU at the 100% mark
all the time. Are they ways to reduce the thread priority of MAIN
itself.
 
C

Christophe Vanfleteren

bigbinc said:
I have a threaded application that I am trying to reduce the priority
for. I have it set at the min and all my while loops are within the
thread, but under windows2000 it still runs the CPU at the 100% mark
all the time. Are they ways to reduce the thread priority of MAIN
itself.

Use the taskmanager of windows 2000 itself (ctrl+alt+delete, taskmanager,
click on the java process, change priority, something like that at least).

But keep in mind that a thread / procces will always use 100% of the cpu if
it is available (and if it actually needs the cpu of course :).

Generally speaking, the thread/process scheduling doesn't kick in unless it
has to compete with other processes for the CPU. Then the kernel will
decide what process gets the cpu time, based on their priority.
 
L

Leon Lambert

Thread priority probably has nothing to do with what you are seeing. A
thread can be at its lowest possible priority and still use 100% cpu
time. Priority is only used when different threads are contending for
the cpu resourse. The one with the higher priority gets it first. If no
other threads need the cpu because they are waiting on something like IO
reads then the low priority one will get all the cpu.

You might consider putting a Sleep in you thread that is using all the
cpu time. If you are looping looking for something to arrive from
another thread you might consider making the thread even driven.

Hope this helps
Leon Lambert
 
B

bigbinc

Leon Lambert said:
Thread priority probably has nothing to do with what you are seeing. A
thread can be at its lowest possible priority and still use 100% cpu
time. Priority is only used when different threads are contending for
the cpu resourse. The one with the higher priority gets it first. If no
other threads need the cpu because they are waiting on something like IO
reads then the low priority one will get all the cpu.

You might consider putting a Sleep in you thread that is using all the
cpu time. If you are looping looking for something to arrive from
another thread you might consider making the thread even driven.

Hope this helps
Leon Lambert

The most complicated way is probably run the application as a service
in the case of Windows. It is an application that takes days to
complete so when my machine is at cpu 100, I normally take off.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top