If I use BackgroundWorker to create two threads, and one thread is writing to a static member variable of a class while the other is reading, does this cause the application to crash?
If no, how does C++/CLI handle it?
Thanks in advance.
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.
It does not cause the application to crash per-se. It causes undefined behavior. Which means, more or less, anything can happen.
What you’re talking about is a race condition. These are bad; your main job when writing multithreaded code is to prevent these from happening.