473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help on Multithreading

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
Nov 20 '05 #1
5 2309
Thanks Fergus,

I have some more info, and i am now not sure if this is a multithreading
issue any more....

When the thread runs out, i raise a event that the processing has completed
that has a handler in the originating for that does some processing. This
processing consists in sending a byte array to a server through a remoting
component.

If i comment out the sending of the byte array, the threads runs smoothly
and they seem to finish properly without any aborts and the number of
threads are not increasing.

The remoting component method works brilliant under all circumstances except
for when a thread aborts. If i set therad.sleep(thread.timeout.indefinately)
for examle everything works like a charm untill all connections has been
used up. I have also thried to sleep the thread for a couple of minutes to
make sure that all file processing is done (which takes less than a second)
before i allow the thread to terminate, but this only delays the high CPU
problem with the same time as i sleep the thread.

Are there any known issues with remoting and multithreading that you are
aware of ?

Thanks

for helping out

Niclas

"Fergus Cooney" <wo****@tesco.net> wrote in message
news:e4**************@TK2MSFTNGP09.phx.gbl...
Hi Niclas,

Sorry about that. :-) We've just about finished a monster marathon
post-thread on multi-threading!!.

Some questions.

1) Have you tried running your thread for, say, 50 seconds and
then killing it ?
This will tell you whether it is the killing or the overlap of
the two threads that is suspect.

2) Are these ThreadPool threads or are the fresh Threads each
time. Have you tried the ThreadPool to see if it makes any difference
?

3) Do you have to kill your Thread or can you have you have it
sleep before tasking on the next task?

4) If none of the above give you useful information, can you post
some code to play with?

Regards
Fergus

Nov 20 '05 #2
Lol, Chris,

Spoke too soon, cos Nick came online and Multithreading in VB.NET
has to be the best chat room going.

Regards,
Fergus
Nov 20 '05 #3
Hi again Niclas,

I'm afraid I've not done any remoting.

Have you explored 2) and 3) and considered 4) from my previous
post?

For 4) I'd want something minimal that's quick to download and
will compile without needing too much, if any, of your app stuff. If
you do send it, use my email.

Another question, too:
You say that you raise an event which then does the remote call.
Which thread is that executed in ?

Awaiting your experimentation.

Regards
Fergus
Nov 20 '05 #4
Fergus,

I just found that my CPU spike was caused by a Do-While loop and not related
to multithreading. Guess i got mislead by all the fancy stuff and had the
solution staring at me all time.

Sorry for wasting your time on this

Thanks for trying to help

Regards

Niclas
"Fergus Cooney" <wo****@tesco.net> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
Hi again Niclas,

I'm afraid I've not done any remoting.

Have you explored 2) and 3) and considered 4) from my previous
post?

For 4) I'd want something minimal that's quick to download and
will compile without needing too much, if any, of your app stuff. If
you do send it, use my email.

Another question, too:
You say that you raise an event which then does the remote call.
Which thread is that executed in ?

Awaiting your experimentation.

Regards
Fergus

Nov 20 '05 #5
Lol. No worries Niclas.

Blinded by the light,
I looked up,
I looked back.
Now everything's all right

Best wishes,
Fergus
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
9
by: Popoxinhxan | last post by:
Dear experts, i want to develop an client application that consume the google search web service. In my MainForm i have a method to retrieve all the search result e.g. GetGoogleResults(). Now i...
5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
9
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
55
by: Sam | last post by:
Hi, I have a serious issue using multithreading. A sample application showing my issue can be downloaded here: http://graphicsxp.free.fr/WindowsApplication11.zip The problem is that I need to...
5
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.