Thread Class

Thread Class

Post by Gurvijay Singh Bhatt » Tue, 10 Aug 1999 04:00:00



Dear everyone,

I have created a class for thread. Once this thread starts to run, it
allocates some memory. In the destructor I deallocate this memory. When
the program finishes then this destructor is not called.

It is very strange, I thought that a destructor is always called.

I am using solaris 2.7 and CC4.2 compiler.

any suggestions.

thanks

GSB

 
 
 

Thread Class

Post by Alessio Gordin » Tue, 10 Aug 1999 04:00:00


Hi Gurvijay,
I suppose you use C++.
If the object is allocated dinamically, then you have to call delete to
call (implicitly) the destructor.
Or maybe you declared a new class (derived from the thread class you
mention), and
istantiate an object of the new class using a pointer to the old class when
deleting it. That makes the base class distructor to be called, unless you
declare as virtual the destructor of the base class.

hth, Alessio


> Dear everyone,

> I have created a class for thread. Once this thread starts to run, it
> allocates some memory. In the destructor I deallocate this memory. When
> the program finishes then this destructor is not called.

> It is very strange, I thought that a destructor is always called.

> I am using solaris 2.7 and CC4.2 compiler.

> any suggestions.

> thanks

> GSB

  alessiog.vcf
< 1K Download

 
 
 

Thread Class

Post by Chris K. Yan » Sat, 14 Aug 1999 04:00:00


would you please give out your code ?  i suppose that
may be the problem in c++ programming , instead of thread-specific
issue.

C.K.Yang


> Dear everyone,

> I have created a class for thread. Once this thread starts to run, it
> allocates some memory. In the destructor I deallocate this memory. When
> the program finishes then this destructor is not called.

> It is very strange, I thought that a destructor is always called.

> I am using solaris 2.7 and CC4.2 compiler.

> any suggestions.

> thanks

> GSB

 
 
 

1. QNX :: pthreads :: C++ :: thread/class communications

Hello,

I have a program that requires 8 threads. Each thread (pthread) is
encapsulated in a C++ class.

I want these threads/classes to be able to access data in other
threads/classes via thier public functions.

My current idea is:

Have a master class containing all of the threads/classes and put all
of the  shared data in the master class. This is not what I really
want to do. But I'm not familiar enough with the language to know what
alternative to use.

The main idea is that I want each classes variables to be only
accessed by that classes member functions and I need the classes to be
able to "talk" to each other to get/send data.

What design method do you recommend?

Best Regards,

Elmer Thomas
http://www.ee.ucr.edu/~ethomas

2. Setting the number of decimal places

3. Looking for simple thread class

4. ?? buy a Sparc or NeXT???

5. Thread class in C++

6. Italian Fiasco--Clone Language Prodigy Dies

7. Solaris/WIN32 Portable Thread Class

8. Sharing variables in thread class -> Static?

9. Thread class constructor with parameters

10. Portable C++ Thread Class

11. threaded class member functions

12. Off the shelf threads classes C++