473,785 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ThreadPool: only 1 ?

hi,

the framework has the ThreadPool class. Very handy.
But as far as I can see this is a singleton (only 1 instance).
Does anybody know a way how to have multiple ThreadPools inside a single
application ?

Regards,

Serge
Nov 15 '05 #1
6 1673
There is only one threadpool per application domain. What are you wanting to
do?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Serge" <se**********@h otmail.com> wrote in message
news:3f******** **************@ reader2.news.sk ynet.be...
hi,

the framework has the ThreadPool class. Very handy.
But as far as I can see this is a singleton (only 1 instance).
Does anybody know a way how to have multiple ThreadPools inside a single
application ?

Regards,

Serge

Nov 15 '05 #2
I have 2 different kind of tasks.

1, delivery system
2, scripting system

these have to run independantly from each other.
Scripts usually take a short time to process, the delivery long. So I don't
want to have the delivery processes hangs up the script processes.

So I wanted to have 2 threadpools running next to each other.
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:u4******** ********@TK2MSF TNGP12.phx.gbl. ..
There is only one threadpool per application domain. What are you wanting to do?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Serge" <se**********@h otmail.com> wrote in message
news:3f******** **************@ reader2.news.sk ynet.be...
hi,

the framework has the ThreadPool class. Very handy.
But as far as I can see this is a singleton (only 1 instance).
Does anybody know a way how to have multiple ThreadPools inside a single
application ?

Regards,

Serge


Nov 15 '05 #3
What would a second threadpool do that the first would not? Each thread in
the pool can already run and block independently of the other threads.
Adding a second threadpool would add more available threads but unless you
needed to manage them yourself to add special capabilities it would not
significantly change anything. You might even find that it slows things down
to add more threads as it increases the amount of context switching.
"Serge" <se**********@h otmail.com> wrote in message
news:3f******** *************@r eader1.news.sky net.be...
I have 2 different kind of tasks.

1, delivery system
2, scripting system

these have to run independantly from each other.
Scripts usually take a short time to process, the delivery long. So I don't want to have the delivery processes hangs up the script processes.

So I wanted to have 2 threadpools running next to each other.
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:u4******** ********@TK2MSF TNGP12.phx.gbl. ..
There is only one threadpool per application domain. What are you
wanting to
do?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Serge" <se**********@h otmail.com> wrote in message
news:3f******** **************@ reader2.news.sk ynet.be...
hi,

the framework has the ThreadPool class. Very handy.
But as far as I can see this is a singleton (only 1 instance).
Does anybody know a way how to have multiple ThreadPools inside a single application ?

Regards,

Serge



Nov 15 '05 #4
Dave <no************ ****@wi.rr.com> wrote:
What would a second threadpool do that the first would not?


It would block different threads. You could have two pools, one with
long-running tasks and one with short-running tasks. If you only add
the right type of task to each pool, you don't get long-running tasks
blocking short-running tasks, which is what you get with a single pool.
You often only want short-running tasks blocking each other and long-
running tasks blocking each other - that way you end up with a much
shorter latency for short-running tasks than long-running tasks.

I agree with the OP - the current ThreadPool is unfortunately limiting
:(

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5
N.K
Go for Custome ThreadPools instead of .NET ThreadPool class, There is
implementation by Mike Woodring (Develop mentor) hosted @ his web
site.
"Serge" <se**********@h otmail.com> wrote in message news:<3f******* **************@ reader1.news.sk ynet.be>...
I have 2 different kind of tasks.

1, delivery system
2, scripting system

these have to run independantly from each other.
Scripts usually take a short time to process, the delivery long. So I don't
want to have the delivery processes hangs up the script processes.

So I wanted to have 2 threadpools running next to each other.
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:u4******** ********@TK2MSF TNGP12.phx.gbl. ..
There is only one threadpool per application domain. What are you wanting

to
do?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Serge" <se**********@h otmail.com> wrote in message
news:3f******** **************@ reader2.news.sk ynet.be...
hi,

the framework has the ThreadPool class. Very handy.
But as far as I can see this is a singleton (only 1 instance).
Does anybody know a way how to have multiple ThreadPools inside a single
application ?

Regards,

Serge


Nov 15 '05 #6

It would block different threads. You could have two pools, one with
long-running tasks and one with short-running tasks. If you only add
the right type of task to each pool, you don't get long-running tasks
blocking short-running tasks, which is what you get with a single pool.
You often only want short-running tasks blocking each other and long-
running tasks blocking each other - that way you end up with a much
shorter latency for short-running tasks than long-running tasks.

I agree with the OP - the current ThreadPool is unfortunately limiting
:(


I never stated otherwise...in fact, in other posts I've advocated custom
thread pools. I just wanted to make sure the OP knew enough to ensure that a
second threadpool would actually be of benefit. Many people mistakenly
believe that they need a large number of threads when it is common that what
they really need is a better understanding of their requirements.

Nov 15 '05 #7

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

Similar topics

5
12345
by: Dan Battagin | last post by:
Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker threads from the ThreadPool. However, eventually (relatively quickly) there become fewer and fewer available worker threads in the pool, until there are 0 and a System.InvalidOperationException occurs with the message: "There were not enough free...
5
2761
by: Duane Pressley | last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up: 1.. A classic ASP page instantiates and calls MethodA on COM+ Class (C1). 2.. MethodA of COM+ class (C1) instantiates and calls MethodB of .NET class (N1). (Note: N1 has been registered using RegASM and is present in the GAC). 3.. MethodB of .NET class (N1) uses the...
6
2759
by: Max Adams | last post by:
Threads and ThreadPool's If I use a ThreadPool how can I tell when a thead in the threadpool has exited? I don't want to set a global member variable I would much rather be able to act on an event Also (failing this ThreadPool issue) is it possible to create an array of Worker Threads, can anyone illustrate with code please Thanks
1
1397
by: doudou-shen | last post by:
I will use threadpool do some work with threadpool . but I haven't any information about it . who can help me! thank a lot
13
2522
by: orekin | last post by:
Hi There I have been programming C# for a couple of months and am trying to master Threading. I understand that ThreadPool uses background threads (see code example in MSDN page titled 'ThreadPool Class ') .... however I would like to ensure that all my ThreadPool threads have completed before I exit my Main function.
10
8781
by: Lenn | last post by:
Hello, I have always used a certain design pattern for multithreaded Windows app; Start new worker thread from UI thread, use events to notify UI threads when something happens, update UI controls using delegates through .BeginInvoke. I came across some code samples recently where ThreadPool class is used to start new threads. My questions; 1. what's the difference? 2. Any performance benefits?
3
2310
by: Kevin | last post by:
Using this: http://msdn2.microsoft.com/en-us/library/3dasc8as(VS.80).aspx as an example I have a question concerning the reuse of objects. In the example 10 instances of the Fibonacci class are made and then all put in the threadpool at once, which is well within the limits of the threadpool. However, what happens if you want to do 10,000 Fibonacci calculations
5
2568
by: =?Utf-8?B?RkxEYXZlTQ==?= | last post by:
I'm developing an application that gets data from 100 sources (via telnet connections, but you can think stock quotes from a webservice if you like). I was planning on using the thread pool (25 at a time). I know I would start all 100 at once and as threads finish, a new thread would become available and the next one would start. However, I need to do this over and over (using an app that will run for days or longer). How can I tell...
3
2498
by: UltimateBanoffee | last post by:
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...
7
7205
by: =?Utf-8?B?cmJEZXZlbG9wZXI=?= | last post by:
The following is from a simple Windows application in VS2005, which has button1 and textbox1 dragged onto a form. In StartThreads(), I call ThreadPool.QueueUserWorkItem(), then call WaitOne(). My expectation is that I would see the text generated in WasteTime() before seeing the "Hey" printout that comes after WaitOne(). Instead, I'm seeing the "Hey" as the first thing to print out in the text box. Any thoughts on why WaitOne() isn't...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.