If we want to use thread specific data in a multithreaded application, how to access those data from another collector thread periodically? Is it possible?
Regards
Ram
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.
Yes, all the threads in the process (application) share the same memory. Just give the address of the data to the collector thread. Be careful with concurrent access: reading some parts of the memory while it’s being updated. You might need to protect some memory zones with mutex.