Is there any way to block a critical area like with Java synchronized in Django?
Share
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.
You can use locks to make sure that only one Thread will access a certain block of code at a time.
To do this, you simply create a
Lockobject then acquire the lock before the block of code you want to synchronize. All the threads must have access to the sameLockobject for this to work. An example:For more information , see http://effbot.org/zone/thread-synchronization.htm.