pthread: return vs pthread_exit()

If the routine of a pthread were to return a pointer to a string (return acts as pthread_exit()) where on earth could that pointer be accessed in the parent thread?

That wouldn't be wise, however if you insisted on doing that, the thread would have to return a dynamically allocated string, so it lived on the heap. The parent would have to delete it when done to prevent a memory leak.

Personally, I don't think thread functions are particularly helpful in C++, you just end up with a different set of problems to solve. It's much better to use a thread class that wraps the data too.
pthread_join( pthread_t child, void** );

Call this function to obtain the return value of the "child" thread
Topic archived. No new replies allowed.