Is there any way to Lock a Method in a Multi-Thread Application ??
NB: to Access a MySQL DataBase
Best regards.
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.
boost scoped_lock is an easy and fool-proof way. Having the lock tied to an object like this automatically releases the lock when for any reason the scope is left. (return, exceptions, …) Edit: Also note c++11: std::lock_guard and std::mutex as told by @Useless
}
this example was found here
http://developer-resource.blogspot.com/2009/01/boost-scoped-lock.html