dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


advertisement
 

Thanks for Not Sharing, Or, How to Define Thread-Local Data

Static data is shared among all threads of the same process. This can lead to race-conditions and bugs, but at last there's a solution: use thread-local storage to allocate per-thread data.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


ntil not long ago, multithreaded apps relied on nonstandard, platform-dependent APIs. C++0x is now in the process of adding a standard threading API, including auxiliary facilities such as thread-local storage. The following sections will explain how to create thread-local data and explain the restrictions on the use of such data.


An object with static storage duration is indiscriminately shared among all the threads of a given process, but you need something quite different—you need a per-thread copy of that object. How do you go about getting it?


Use thread-local variables to declare objects that are unique to a thread.





Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date