Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why i should use pthread_detach?

Posted on 2006-10-25
1
Medium Priority
?
1,442 Views
Last Modified: 2008-01-09
Can someone explain me the pthread_detach() function?

Why i should use it and what is the usage for it?
0
Comment
Question by:woigl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 45

Accepted Solution

by:
sunnycoder earned 1000 total points
ID: 17801864
Hi woigl,

Resource taken by a thread would remain occupied until a pthread_join() returns. i.e. resources are not freed even after calling pthread_exit(). For a detached pthread, memory reousrces are freed upon thread exit and can be recycled immediately.
You would like such an arrangement in say a threaded server where you keep a pool of min no of server threads and spawn, kill them as required. It is not necessary to know if processing completed successfully (webserver) and you would not like to join every thread, nor would it be convenient to do so.

Cheers!
sunnycoder
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question