c++ with pthread?

Erich Dollansky oceanare at pacific.net.sg
Sat Nov 5 20:07:52 PST 2005


Nicolas Blais wrote:
> It compiles and works fine. I'm trying to make the same program in C++.  Is 
> the syntax for pthreading the same as in C? I was wondering if someone can 
> point me in the right direction.
the threading stuff stays the same.

> Also, is there anything I should be worried about when using pthread and C++? 
> (Some years ago, I heard that FreeBSD's pthread didn't like C++... could be a 
> false rumour)

You cannot use classes directly with threading functions. Your classes 
must be aware of threading. You need some mechanism to protect classes 
which are not threadsafe if more than one thread could access an object 
at te same moment of time.

This is a general problem of threading which might causes problems.

Do not forget that C++ uses additional data in objects which the 
programmer does not see.


More information about the freebsd-threads mailing list