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. Thread Query in vc++

Thread Query in vc++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++cssdatabaseperformance
3 Posts 3 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.
  • M Offline
    M Offline
    madhu_v
    wrote on last edited by
    #1

    I have developed a VC++ program based on communication(online program). In the application,i have used two threads for computation. The working time of two threads is very less. my query is ... 1)If the thread is opened and closed each time for computation, will the program memory grow??? or what is the drawback?? OR Is it advisable to run the thread with sleep mode without closing the thread?? Help me...... Empty mind is Devils-Workshop

    T S 2 Replies Last reply
    0
    • M madhu_v

      I have developed a VC++ program based on communication(online program). In the application,i have used two threads for computation. The working time of two threads is very less. my query is ... 1)If the thread is opened and closed each time for computation, will the program memory grow??? or what is the drawback?? OR Is it advisable to run the thread with sleep mode without closing the thread?? Help me...... Empty mind is Devils-Workshop

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      madhu_v wrote:

      1)If the thread is opened and closed each time for computation, will the program memory grow??? or what is the drawback?? OR

      every time when thread is created it will take some memory.. i.e. overhead.., if computation take less time , then why creating thread , why not include in main program!

      madhu_v wrote:

      s it advisable to run the thread with sleep mode without closing the thread??

      yes and no! wholly depend upon the software design.. you can use event or waitforsingleobject to make thread wait

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

      1 Reply Last reply
      0
      • M madhu_v

        I have developed a VC++ program based on communication(online program). In the application,i have used two threads for computation. The working time of two threads is very less. my query is ... 1)If the thread is opened and closed each time for computation, will the program memory grow??? or what is the drawback?? OR Is it advisable to run the thread with sleep mode without closing the thread?? Help me...... Empty mind is Devils-Workshop

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        Thread creation is a relatively expensive operation, both in space and time. If you spawn a thread and let it run to completion nothing is permanently lost however - assuming of course that your code doesn't contain any memory (or other resource) leaks. If you’ve got lots of small tasks you want to run in another thread and you spawn a thread for each task you could easily find that the thread creation and destruction time dominates and causes performance problems. One solution to this is to use a thread pool. See the QueueUserWorkItem API.

        Steve

        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