I have a variable in my static function, but I would like it to be static across each thread.
How can I allocate memory for my C ++ class so that each thread has its own copy of the class instance?
AnotherClass::threadSpecificAction() { // How to allocate this with thread local storage? static MyClass *instance = new MyClass(); instance->doSomething(); }
This is on Linux. I do not use C ++ 0x and this is gcc v3.4.6.
c ++ multithreading new-operator linux thread-local-storage
WilliamKF May 16 '11 at 17:50 2011-05-16 17:50
source share