M
MS Newsgroups
Hi,
I have an application that runs a timer and executes a method in a class as
a new thread every 60 seconds, the thread takes 65 seconds to execute so
there is a 5 second overlap when 2 threads are running.
The problem i have is that i am experiencing sudden high CPU utilization
that lasts for a couple of seconds, and i believe that i have managed to tie
this down to occuring when the thread is terminated.
If I in the end of the thread use
threading.thread.currentthread.abort
threading.thread.currentthread.join
as the documentation specifies is the correct way of terminating a thread, i
get a 3-4 second 100% CPU spike that my application can't live with
If I don't use any code at all in the end of the method or only specifies
threading.thread.currentthread.join, everything runs smooth for about 25
minutes and then no more threads are executed and if i monitor the .Net CLR
Locking & Threads-> # Current recogized threads i can see that this value
increases until it reaches 25 which i believe is the default maximum number
of threads the CLR accepts.
Question is:
What am i doing wrong ? Am i supposed to actively abort my threads and if so
why do i get this CPU spike ? Are there any other ways of ending a thread ?
Why is the number of threads increasing, is there a way to "reclaim" threads
that has finished
Appreciate all help on this
Regards
Niclas
I have an application that runs a timer and executes a method in a class as
a new thread every 60 seconds, the thread takes 65 seconds to execute so
there is a 5 second overlap when 2 threads are running.
The problem i have is that i am experiencing sudden high CPU utilization
that lasts for a couple of seconds, and i believe that i have managed to tie
this down to occuring when the thread is terminated.
If I in the end of the thread use
threading.thread.currentthread.abort
threading.thread.currentthread.join
as the documentation specifies is the correct way of terminating a thread, i
get a 3-4 second 100% CPU spike that my application can't live with
If I don't use any code at all in the end of the method or only specifies
threading.thread.currentthread.join, everything runs smooth for about 25
minutes and then no more threads are executed and if i monitor the .Net CLR
Locking & Threads-> # Current recogized threads i can see that this value
increases until it reaches 25 which i believe is the default maximum number
of threads the CLR accepts.
Question is:
What am i doing wrong ? Am i supposed to actively abort my threads and if so
why do i get this CPU spike ? Are there any other ways of ending a thread ?
Why is the number of threads increasing, is there a way to "reclaim" threads
that has finished
Appreciate all help on this
Regards
Niclas