?
Solved

Why i should use pthread_detach?

Posted on 2006-10-25
1
Medium Priority
?
1,413 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

752 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