Hi,
I'm having trouble getting shared_ptr objects and threads to work in
harmony.
It may just be that i don't know enough about threads to solve this, but
i'm getting undefined behaviour in the code posted at the end of this mail.
i'm not worried about the order that the threads run in (as this is just
an example of the problem i'm having in a simple multi-threaded web
server i'm working on), but it seems like the shared_ptr object may be
getting deleted before the last thread gets to execute.
i.e. some sample output i'm getting is
0
1
3
4
-572662307
and
1
2
3
3
-572662307
i think i'm probably missing some mutex's or something, but i can't
figure it out
can anyone give me any pointers on how to get around this problem?
thanks in advance
--Tristan
#include <iostream>
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
#include