In what situations would one want to use reentrant locks versus normal locks?
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.
I presume a reentrant lock would have some additional overhead compared to a normal lock – to check what thread is acquiring the lock.
Therefore, if you know that under normal operation a thread will only acquire the lock once before releasing it again, you may gain some performance by using a normal lock. This could be particularly beneficial in tight loops, etc.