Menu

Waiting for threads to finish...

Help
Anonymous
2001-03-12
2001-03-13
  • Anonymous

    Anonymous - 2001-03-12

    I'm trying to use this common c++ library on a project, and I'm quite satified with it.
    Yet, there is something I haven't been able to code cleanly, using the provided API:
    My application needs to start a bunch of threads and to wait for them to finish before continuing with its computation.

    I've tried deleting the threads hoping that the main thread would block waiting for them, but the threads got inesorably deleted before they could attempt to do anything useful.
    Does your API provide a way to achieve this behaviour?

    Thanks a lot

    bye

     
    • David Sugar

      David Sugar - 2001-03-13

      A delete normally performs a "join", and hence will wait for the thread to terminate before returning.  If you are creating a derived class and calling it's virtual destructor, then you may need to add Terminate() to the derived classes destructor.  Also, depending on what the thread does and which services it invokes, you may need to play with setCancel before the thread will cancel, or add Yield points in any loops in your code where appropriate to permit cancellation to occur.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.