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. Syncronizing thread destruction?

Syncronizing thread destruction?

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelptutorialquestion
4 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.
  • C Offline
    C Offline
    clintsinger
    wrote on last edited by
    #1

    Hi Everyone, I have an application that has a thread within a thread. When I delete the parent it is suppose to delete the child thread within the destructor. Unforetunately I am running into problems where the memory has already been freed (at least that is what I think has happened) and trying to free the resources are used by the threads. When I run the application through boundschecker I don't see this problem at all so I think it has to do with some race condition. Is there some documentation on how to properly and effectively control the destruction of threads? Cheers, Clint

    N V 2 Replies Last reply
    0
    • C clintsinger

      Hi Everyone, I have an application that has a thread within a thread. When I delete the parent it is suppose to delete the child thread within the destructor. Unforetunately I am running into problems where the memory has already been freed (at least that is what I think has happened) and trying to free the resources are used by the threads. When I run the application through boundschecker I don't see this problem at all so I think it has to do with some race condition. Is there some documentation on how to properly and effectively control the destruction of threads? Cheers, Clint

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      What do you mean by "delete" the thread? The parent thread should ask the child thread to end, and then it should end. Using CEvent is a good way to do this. Neville Franks, Author of ED for Windows. www.getsoft.com Make money with our new Affilate program

      1 Reply Last reply
      0
      • C clintsinger

        Hi Everyone, I have an application that has a thread within a thread. When I delete the parent it is suppose to delete the child thread within the destructor. Unforetunately I am running into problems where the memory has already been freed (at least that is what I think has happened) and trying to free the resources are used by the threads. When I run the application through boundschecker I don't see this problem at all so I think it has to do with some race condition. Is there some documentation on how to properly and effectively control the destruction of threads? Cheers, Clint

        V Offline
        V Offline
        valikac
        wrote on last edited by
        #3

        Post an example of how you terminate the child thread. Kuphryn

        C 1 Reply Last reply
        0
        • V valikac

          Post an example of how you terminate the child thread. Kuphryn

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

          I was using an user interface thread to do the trick. I changed over to a worker thread and now everything seems to be better. I think the problem had to do with the self deleting nature of user threads. Now I explicitly control who deletes and when. Sincerly, Clint

          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