Re: Why does Thread class not support IDisposable?
- From: "Chris Mullins [MVP - C#]" <cmullins@xxxxxxxxx>
- Date: Fri, 7 Dec 2007 15:06:27 -0800
You're still going to have problems.
If you've got all of the threadpool threads busy, you may end up deadlocking
the entire threadpool.
The think that keeps being danced around, is that a solution like this
performance waaaaay worse than a single-threaded soultuion. You're using all
system resources creating and scheduling threads. Almost no work is being
done towards your actual problem set.
Abuse of threads, be they custom threads, threadpool threads, IOCP threads,
or some new type I'm not aware of, all hurts performance and is an indicator
of a fundamentaly flawed desing.
.... breaking your work down into chunks, and passing those chungs to a set
of threads via a queue, is often the right design. You just can't point
1000+ threads at the queue and say "go!". At least not on a 1x, 2x, 4x, 8x
processor box.
--
Chris
"Martin Carpella" <martin.carpella@xxxxxxx> wrote in message
news:87wsrqur1c.fsf@xxxxxxxxxxxxxxxxxxxxx
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> writes:
Instead, you just an ever-growing queue of new work items for the thread
pool.
Yes, I completely agree with you. In my opinion it is exactly this queue
which will "solve"/hide the error, as there are never "too many"
threads, as the ThreadPool won't grow beyond its maximum thread count.
It's true, using a thread pool can be a nice way to handle certain
aysynchronous operations. But if you've got a bug with regular threads,
you've still got a bug using thread pool threads.
Again, agreed. If the problem is that there are too many concurrent
requests, though, the TreadPool _could_ be the solution, as, as you
mentioned, the work items get queued instead of spawning a new thread.
Best regards,
Martin
.
- Follow-Ups:
- Re: Why does Thread class not support IDisposable?
- From: Martin Carpella
- Re: Why does Thread class not support IDisposable?
- From: Peter Duniho
- Re: Why does Thread class not support IDisposable?
- References:
- Why does Thread class not support IDisposable?
- From: Creativ
- Re: Why does Thread class not support IDisposable?
- From: Jon Skeet [C# MVP]
- Re: Why does Thread class not support IDisposable?
- From: Creativ
- Re: Why does Thread class not support IDisposable?
- From: Jon Skeet [C# MVP]
- Re: Why does Thread class not support IDisposable?
- From: Creativ
- Re: Why does Thread class not support IDisposable?
- From: Jon Skeet [C# MVP]
- Re: Why does Thread class not support IDisposable?
- From: Creativ
- Re: Why does Thread class not support IDisposable?
- From: Martin Carpella
- Re: Why does Thread class not support IDisposable?
- From: Peter Duniho
- Re: Why does Thread class not support IDisposable?
- From: Martin Carpella
- Why does Thread class not support IDisposable?
- Prev by Date: Re: Abstract Classes and Interfaces relationship between C# and VB.Net
- Next by Date: Re: OOP Question
- Previous by thread: Re: Why does Thread class not support IDisposable?
- Next by thread: Re: Why does Thread class not support IDisposable?
- Index(es):
Relevant Pages
|