After I create a certain number of threads, my program crashes [Unix]

By default, POSIX threads are created non-detached. You need to perform a join on each non-detached thread, or else storage will never be freed up when they exit. As an alternative, you can create detached threads, for which storage will be freed as soon as they exit. This latter approach is generally better; you should only create non-detached threads if you explicitly need to know when or if they exit.

2 comments on “After I create a certain number of threads, my program crashes [Unix]
  1. William Rogers says:

    After my program runs for 1-3 hours, all the threads terminate but I cannot know exactly what caused this. Is there a way to determine which thread terminates first?

  2. Laptop Bekas says:

    have you check running services? type top to check it

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>