ThreadPool: only 1 ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Serge

    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


  • Alvin Bruney

    #2
    Re: ThreadPool: only 1 ?

    There is only one threadpool per application domain. What are you wanting to
    do?

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Serge" <serge_knecht@h otmail.com> wrote in message
    news:3f9c48b2$0 $3623$ba620e4c@ reader2.news.sk ynet.be...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • Serge

      #3
      Re: ThreadPool: only 1 ?

      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:u4EV9%23An DHA.2528@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > There is only one threadpool per application domain. What are you wanting[/color]
      to[color=blue]
      > do?
      >
      > --
      >
      >
      > -----------
      > Got TidBits?
      > Get it here: www.networkip.net/tidbits
      > "Serge" <serge_knecht@h otmail.com> wrote in message
      > news:3f9c48b2$0 $3623$ba620e4c@ reader2.news.sk ynet.be...[color=green]
      > > 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
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Dave

        #4
        Re: ThreadPool: only 1 ?

        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" <serge_knecht@h otmail.com> wrote in message
        news:3f9c50e7$0 $272$ba620e4c@r eader1.news.sky net.be...[color=blue]
        > 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[/color]
        don't[color=blue]
        > 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:u4EV9%23An DHA.2528@TK2MSF TNGP12.phx.gbl. ..[color=green]
        > > There is only one threadpool per application domain. What are you[/color][/color]
        wanting[color=blue]
        > to[color=green]
        > > do?
        > >
        > > --
        > >
        > >
        > > -----------
        > > Got TidBits?
        > > Get it here: www.networkip.net/tidbits
        > > "Serge" <serge_knecht@h otmail.com> wrote in message
        > > news:3f9c48b2$0 $3623$ba620e4c@ reader2.news.sk ynet.be...[color=darkred]
        > > > 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[/color][/color][/color]
        single[color=blue][color=green][color=darkred]
        > > > application ?
        > > >
        > > > Regards,
        > > >
        > > > Serge
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: ThreadPool: only 1 ?

          Dave <noSpamdlevineN NTP2@wi.rr.com> wrote:[color=blue]
          > What would a second threadpool do that the first would not?[/color]

          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 - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          • N.K

            #6
            Re: ThreadPool: only 1 ?

            Go for Custome ThreadPools instead of .NET ThreadPool class, There is
            implementation by Mike Woodring (Develop mentor) hosted @ his web
            site.


            "Serge" <serge_knecht@h otmail.com> wrote in message news:<3f9c50e7$ 0$272$ba620e4c@ reader1.news.sk ynet.be>...[color=blue]
            > 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:u4EV9%23An DHA.2528@TK2MSF TNGP12.phx.gbl. ..[color=green]
            > > There is only one threadpool per application domain. What are you wanting[/color]
            > to[color=green]
            > > do?
            > >
            > > --
            > >
            > >
            > > -----------
            > > Got TidBits?
            > > Get it here: www.networkip.net/tidbits
            > > "Serge" <serge_knecht@h otmail.com> wrote in message
            > > news:3f9c48b2$0 $3623$ba620e4c@ reader2.news.sk ynet.be...[color=darkred]
            > > > 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
            > > >
            > > >[/color]
            > >
            > >[/color][/color]

            Comment

            • Dave

              #7
              Re: ThreadPool: only 1 ?

              [color=blue]
              >
              > 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
              > :([/color]

              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.



              Comment

              Working...