When you allocate some TLS for thread A in a slot, can you then access that same slot from Thread B?
Is it internally synchronized or how does that work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The local variables of a function are unique to each thread that runs the function. This can be accomplished with help of TLS which as already mentioned is local for each thread.
If you want to share some data between threads there are several options starting from using global or static variables up to memory mapped files and etc… also check thread synchronization if you need to share data between threads.
The following diagram illustrates how TLS works.
For more details check MSDN.
(source: microsoft.com)