I have a code block like this:
if(supportsSomeStuff()){
.....
.....
}
else {
.....
.....
}
Now I want to have this code block in multiple reads, single write locks. In this case, it is better to lock the if statement and release the lock after if, then lock in the else statement and release it when you're done?
Or, can I just block this if-else case and free it when done?
If I need to decide on this, what factors need to be taken into account?
Please let me know if you need more information.
Barry source
share