A thread disturbs too much another.

  • Thread starter Thread starter d_well
  • Start date Start date
D

d_well

Hi,

I am making a multithreaded application. I have a thread for the GUI
and another for a calcul. The thread for the calcul need a lot of CPU
and it is heavy. My problem is when I run the two threads, the thread
for the calcul disturbs a lot the GUI thread. I would like that my GUI
thread run fluently and my thread for the calcul be in background
without disturb the GUI thread. I tried to modify the priorities to
lowest for the calculation thread and highest for the GUI thread but
the problem is still the same. I tried too to put the parameter
isBackground to true for the calculation thread but doesn't work. How
can I manage my threads for that my calculation thread donesn't
disturb my GUI thread.

Thanks

Fabien
 
Fabien,

If you have the calculation on another thread, then it really doesn't
have to do with too many threads. The issue here is that your background
thread is probably taking up too many resources, to the point where the
whole machine is slowed down.

Is there a way you can break up the task into smaller chunks, and
dispose of any resources at the end of processing the chunk? For example,
if you are processing one million records in a table, maybe you can download
one thousand at a time, instead of the total one million (which would put a
strain on the system).

Hope this helps.
 
d_well said:
Hi,

I am making a multithreaded application. I have a thread for the GUI
and another for a calcul. The thread for the calcul need a lot of CPU
and it is heavy. My problem is when I run the two threads, the thread
for the calcul disturbs a lot the GUI thread. I would like that my GUI
thread run fluently and my thread for the calcul be in background
without disturb the GUI thread. I tried to modify the priorities to
lowest for the calculation thread and highest for the GUI thread but
the problem is still the same. I tried too to put the parameter
isBackground to true for the calculation thread but doesn't work. How
can I manage my threads for that my calculation thread donesn't
disturb my GUI thread.

Thanks

Fabien

You realy need a dual CPU machine for this. If you have a long running
thread that only consumes CPU resources, and you only have a single CPU box,
it will always disturb the other threads.
One possible solution is to insert short sleeps while calculating, say a
sleep of 20ms per 100ms, if possible.

Willy.
 
But I think I can run that on only one machine. Because I tried to do
two separate applications and run the both at the same time and when I
change the priority of the main process to a value greater than the
calculation process all work right. The problem is that here I used to
different applications (two different processes) and I would like
integrate all in only one aplication.

Fabien
 
Back
Top