ThreadPool and Threads! Help please!

U

UltimateBanoffee

Hi,

I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.QueueWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all call on an aspx that takes a couple of seconds to process. I
gather 100 sessions are active, but does that mean 100 threads from
the TreadPool will be required?

My question basically is when/why are threads from the ThreadPool
allocated when ThreadPool.QueueWorkItem is not used.

Thanks to anyone who has time to clear this up for me :eek:)
Jonathan
 
G

Guest

A soon as a threadpool thread completes it's work it becomes available to
process another unit of work immediately. So even if you actually had 100
"simultaneous" requests (which is hardly possible) this means that less than
100 threadpool threads might be in use at any given time. Additionally, the
Threadpool can be used without explicitly using its QueueUserWorkItem method.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 
P

Patrice

As a web application can obviously have multiple requests at the same time,
this is of course built in the basic ASP.NET/IIS infrastructure. The
web.config file allows to control some of those parameters such as the max
number of worker threads etc...

(http://msdn.microsoft.com should provide some details about the ASP.NET
architecture).
 
S

Samuel R. Neff

ASP.NET has it's own pool of worker threads for processing HTTP
requests, it does not use the same ThreadPool for those requests. I
believe this pool is much larger than the standard ThreadPool.

ThreadPool is used by many framework classes though, including most
(but not all) calls to BeginXXX methods (WinForms has it's own async
mechanism as does socket IO).

Also note that when the ThreadPool does get exhauseted, queued items
still run they just have to wait until a thread pool thread becomes
available. For that reason it's advised never to run long-running
tasks on a thread-pool thread, use a custom thread for that.

HTH,

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Merge sort and threads 0
About my threadpool engine 1
About my threadpool engine... 0
Please help me!!! 3
Hello and Help please :-) 1
Help please 8
threadpool and ui paint 6
ThreadPool problem 3

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top