Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. what is maximum num of threads use in application?

what is maximum num of threads use in application?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
16 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, please tell me what is the maximum number of threads that i use in my SDI type application. its is safe to generate and handle this large number of threads in application,or there is any othre option to handle this. i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread. please help me for this. thanks in advance.

    _ C M 3 Replies Last reply
    0
    • L Le rner

      Hi all, please tell me what is the maximum number of threads that i use in my SDI type application. its is safe to generate and handle this large number of threads in application,or there is any othre option to handle this. i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread. please help me for this. thanks in advance.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      It is not a good idea to have a large number of threads. You must instead have a fixed number of threads and make use of them for your processing. As for your question on the maximum number of threads, read this blog entry - Pushing the Limits of Windows: Processes and Threads[^]

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      L 1 Reply Last reply
      0
      • _ _Superman_

        It is not a good idea to have a large number of threads. You must instead have a fixed number of threads and make use of them for your processing. As for your question on the maximum number of threads, read this blog entry - Pushing the Limits of Windows: Processes and Threads[^]

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        L Offline
        L Offline
        Le rner
        wrote on last edited by
        #3

        «_Superman_» wrote:

        It is not a good idea to have a large number of threads. You must instead have a fixed number of threads and make use of them for your processing.

        please explain me better idea and approach for this. if possible please provide me any sample application or example.

        R 1 Reply Last reply
        0
        • L Le rner

          Hi all, please tell me what is the maximum number of threads that i use in my SDI type application. its is safe to generate and handle this large number of threads in application,or there is any othre option to handle this. i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread. please help me for this. thanks in advance.

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Rule of thumb: "If in doubt then use just one thread. If you're really in doubt then use just one thread. If you actually need to waste system resources then use two threads". On the serious side,

          Le@rner wrote:

          i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread.

          You would experience no performance gain doing this, unless you have a CPU core per thread. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          N D 2 Replies Last reply
          0
          • L Le rner

            «_Superman_» wrote:

            It is not a good idea to have a large number of threads. You must instead have a fixed number of threads and make use of them for your processing.

            please explain me better idea and approach for this. if possible please provide me any sample application or example.

            R Offline
            R Offline
            rp_suman
            wrote on last edited by
            #5

            You could find lot of articles by googling. Here some useful links: Multithreading with C++ and MFC [^] Multithreaded Applications using MFC[^] Creating a Multithreaded SDI Application[^] Regards

            -- "Programming is an art that fights back!"

            1 Reply Last reply
            0
            • C CPallini

              Rule of thumb: "If in doubt then use just one thread. If you're really in doubt then use just one thread. If you actually need to waste system resources then use two threads". On the serious side,

              Le@rner wrote:

              i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread.

              You would experience no performance gain doing this, unless you have a CPU core per thread. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              N Offline
              N Offline
              Niklas L
              wrote on last edited by
              #6

              CPallini wrote:

              You would experience no performance gain doing this, unless you have a CPU core per thread.

              Blocking IO can be a good reason for (over-)threading for performance.

              home

              C 1 Reply Last reply
              0
              • N Niklas L

                CPallini wrote:

                You would experience no performance gain doing this, unless you have a CPU core per thread.

                Blocking IO can be a good reason for (over-)threading for performance.

                home

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                True, but that's not the OP case (or, at least, that doesn't look like the OP case). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                1 Reply Last reply
                0
                • L Le rner

                  Hi all, please tell me what is the maximum number of threads that i use in my SDI type application. its is safe to generate and handle this large number of threads in application,or there is any othre option to handle this. i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread. please help me for this. thanks in advance.

                  M Offline
                  M Offline
                  Maximilien
                  wrote on last edited by
                  #8

                  Le@rner wrote:

                  i have an ListCtrl and this have hundred of items

                  Le@rner wrote:

                  ,i want to check all item at same time

                  crap. just think about that for one 1 second. Anyway, depending on what "check" really means it can a _very_ performance degradation. For a better solution to your problem, would be to use the CListCtrl in Virtual Mode, see MSDN[^] for more information.

                  Watched code never compiles.

                  N 1 Reply Last reply
                  0
                  • C CPallini

                    Rule of thumb: "If in doubt then use just one thread. If you're really in doubt then use just one thread. If you actually need to waste system resources then use two threads". On the serious side,

                    Le@rner wrote:

                    i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread.

                    You would experience no performance gain doing this, unless you have a CPU core per thread. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    CPallini wrote:

                    You would experience no performance gain doing this...

                    Actually he would. I recently put together a little utility that does exactly what the OP wants (I offered it to him but he was not interested). When it had only one thread, it took over 20 minutes to check all of the links (i.e., URLs) in the list (slightly less than 500). When I changed it to check each link in its own thread, the time was dropped to around 2 minutes.

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Man who follows car will be exhausted." - Confucius

                    C L 2 Replies Last reply
                    0
                    • D David Crow

                      CPallini wrote:

                      You would experience no performance gain doing this...

                      Actually he would. I recently put together a little utility that does exactly what the OP wants (I offered it to him but he was not interested). When it had only one thread, it took over 20 minutes to check all of the links (i.e., URLs) in the list (slightly less than 500). When I changed it to check each link in its own thread, the time was dropped to around 2 minutes.

                      "One man's wage rise is another man's price increase." - Harold Wilson

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      "Man who follows car will be exhausted." - Confucius

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #10

                      DavidCrow wrote:

                      check all of the links (i.e., URLs)

                      This piece of info is missing in the original post. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      D 1 Reply Last reply
                      0
                      • C CPallini

                        DavidCrow wrote:

                        check all of the links (i.e., URLs)

                        This piece of info is missing in the original post. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                        [My articles]

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        CPallini wrote:

                        This piece of info is missing in the original post.

                        Yeah, see here for a recap.

                        "One man's wage rise is another man's price increase." - Harold Wilson

                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                        "Man who follows car will be exhausted." - Confucius

                        C 1 Reply Last reply
                        0
                        • D David Crow

                          CPallini wrote:

                          This piece of info is missing in the original post.

                          Yeah, see here for a recap.

                          "One man's wage rise is another man's price increase." - Harold Wilson

                          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                          "Man who follows car will be exhausted." - Confucius

                          C Offline
                          C Offline
                          CPallini
                          wrote on last edited by
                          #12

                          OK. Now that makes sense. Thank you. :)

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                          [My articles]

                          1 Reply Last reply
                          0
                          • M Maximilien

                            Le@rner wrote:

                            i have an ListCtrl and this have hundred of items

                            Le@rner wrote:

                            ,i want to check all item at same time

                            crap. just think about that for one 1 second. Anyway, depending on what "check" really means it can a _very_ performance degradation. For a better solution to your problem, would be to use the CListCtrl in Virtual Mode, see MSDN[^] for more information.

                            Watched code never compiles.

                            N Offline
                            N Offline
                            Niklas L
                            wrote on last edited by
                            #13

                            A virtual list control will not help him here. Besides, he has just "hundreds of items", which is not a lot.

                            home

                            M 1 Reply Last reply
                            0
                            • N Niklas L

                              A virtual list control will not help him here. Besides, he has just "hundreds of items", which is not a lot.

                              home

                              M Offline
                              M Offline
                              Maximilien
                              wrote on last edited by
                              #14

                              I did not know what "Check" was ... :~

                              Watched code never compiles.

                              L 1 Reply Last reply
                              0
                              • D David Crow

                                CPallini wrote:

                                You would experience no performance gain doing this...

                                Actually he would. I recently put together a little utility that does exactly what the OP wants (I offered it to him but he was not interested). When it had only one thread, it took over 20 minutes to check all of the links (i.e., URLs) in the list (slightly less than 500). When I changed it to check each link in its own thread, the time was dropped to around 2 minutes.

                                "One man's wage rise is another man's price increase." - Harold Wilson

                                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                "Man who follows car will be exhausted." - Confucius

                                L Offline
                                L Offline
                                Le rner
                                wrote on last edited by
                                #15

                                DavidCrow wrote:

                                I offered it to him but he was not interested

                                no sir its not right i really intrested and also reply for this and ask for code of given exe but u not replay me. can u please explain it with example or provide me any sample example. please help me for this. i really need it.

                                1 Reply Last reply
                                0
                                • M Maximilien

                                  I did not know what "Check" was ... :~

                                  Watched code never compiles.

                                  L Offline
                                  L Offline
                                  Le rner
                                  wrote on last edited by
                                  #16

                                  Maximilien wrote:

                                  I did not know what "Check" was ...

                                  i have an list control and there is so much items. list control have list of site links here i want to chk all links. but all links have diffrent interval time to chk the link status so thats why not able to chk with single thread or function. please tell me how can i do this for each and every link individually.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups