Thread safety with heap-allocated memory
Posted
by incrediman
on Stack Overflow
See other posts from Stack Overflow
or by incrediman
Published on 2010-05-16T23:54:52Z
Indexed on
2010/05/17
0:00 UTC
Read the original article
Hit count: 157
I was reading this: http://en.wikipedia.org/wiki/Thread_safety
Is the following function thread-safe?
void foo(int y){
int * x = new int[50];
/*...do some stuff with the allocated memory...*/
delete x;
}
In the article it says that to be thread-safe you can only use variables from the stack. Really? Why? Wouldn't subsequent calls of the above function allocate memory elsewhere?
© Stack Overflow or respective owner