954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

multithreading & destructor call.

Hi,
I am doin a multithreading program in c++.
......
class thr
{......
public:
d =new char[35];
......
void start(){...start thread by calling function run..}
void run(){...}
int joining(){..join all threads}
~thr(){delete []d;}
};

In the program I am creating all threads,calling start on all thread objects and then calling joining on all thread objects.

Now I want to know when will this destructor be called for each thread object?Finally altogether or when each thread joins..or....
confused state :-|....help me out,pls.
thanks

kararu
Junior Poster in Training
50 posts since Sep 2006
Reputation Points: 20
Solved Threads: 0
 

I've just explained how to do threads with classes here
http://forums.devshed.com/c-programming-42/multithreaded-server-class-393019.html

To be honest, tackling threads before you've got the rest of C++ well sorted out in your head is a receipe for disaster.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You