multithreading & destructor call.

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 50
Reputation: kararu is an unknown quantity at this point 
Solved Threads: 0
kararu kararu is offline Offline
Junior Poster in Training

multithreading & destructor call.

 
0
  #1
Oct 12th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: multithreading & destructor call.

 
0
  #2
Oct 12th, 2006
I've just explained how to do threads with classes here
http://forums.devshed.com/c-programm...ss-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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1704 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC