Re: Out of control threads
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam>
- Date: Fri, 23 Feb 2007 04:30:24 GMT
In this case, I would use the threadpool and queue up the threads. You get
the benefits of the parallel operations but don't saturate your physical
resources.
Mike.
"Ashot Geodakov" <a_geodakov@xxxxxxxxxxx> wrote in message
news:OOIRsIwVHHA.528@xxxxxxxxxxxxxxxxxxxxxxx
Hmm, and if you needed to visit 1000 websites (or databases) would you
have created a 1000 threads?
I am sure the method works great, but I still have doubts whether or not
it can give you any gain in performance.
There's still a network cable which allows only this much information to
pass at any moment. Say, 100 kbits per second. What if you need 100 kbits
from each of the 10 websites? They'll not come all in one second because
of multithreading. They'll take exactly 10 seconds.
And during multithreading doesn't CPU pass a token between threads and run
just a portion of a thread funtion and then move on to the next thread?
How is it different from running thread functions sequentially? Besides
all the extra steps that CPU has to take because of multithreading?
Sometimes you may want to do 10 things in parralel (like visit 10
websites and scrape some info). This is much faster when you use 10
threads, then doing it sequentially, as the bottleneck is latency, not
CPU. I have personally used a method described above, and it works
great.
You may need to retrieve values from different databases, and then
perform some calculation using them. You can only start the
calculation once you have the 10 values.
.
- Follow-Ups:
- Re: Out of control threads
- From: ujjc001
- Re: Out of control threads
- References:
- Out of control threads
- From: ujjc001
- Re: Out of control threads
- From: Ashot Geodakov
- Re: Out of control threads
- From: mangist
- Re: Out of control threads
- From: Ashot Geodakov
- Out of control threads
- Prev by Date: Re: Out of control threads
- Next by Date: RE: PreTranslateMessage and .NET
- Previous by thread: Re: Out of control threads
- Next by thread: Re: Out of control threads
- Index(es):
Relevant Pages
|