Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am bit confused with pthread_exit, join & detach. I call pthread_create from one thread and then in next line I do pthread_join of newly created thread id. In ...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Posts
    28

    pthread_exit

    Hi,
    I am bit confused with pthread_exit, join & detach.

    I call pthread_create from one thread and then in next line I do pthread_join of newly created thread id. In this case can I do pthread_exit in the newly created thread?

    I believe if we do pthread_exit, the thread will be distroyed as well as its memory associated with it will be freed. Is my understanding correct?

    Thanks in Advance!!

  2. #2
    Just Joined! garry_3peace's Avatar
    Join Date
    Oct 2008
    Posts
    67
    As far as I know, you don't really need to use pthread_exit actually. Coz if the thread exit by itself, its already free the memory. We use pthread_exit just like we use exit() in normal program, to exit in the middle of program.

    In order to exit from the newly created thread, you must put the pthread_exit in the thread routine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...