Stacks in Muti-threaded program
Hi all
Since in a muti-threaded program program address space is shared between the threads, will threre be a single stack for all the threads and do i we need to take care of synchronisation while modifying the local variables?? -ARUN KA |
All threads in a process share the same global address space: true.
But each thread will have it's own stack (each allocated from that process's address space). So yes, any local variable you allocate from the stack (i.e. any/all "automatic variables") are by definition thread-safe. You are correct - you do *not* need to synchronize local, "automatic" variables. |
All times are GMT -5. The time now is 07:18 PM. |