You are tasked with designing a system where multiple threads need to access a shared resource (e.g., a list of tasks). How would you ensure that:
The threads don't interfere with each other (i.e., avoid race conditions)?
The performance of the system is optimized (i.e., threads don't unnecessarily block each other)?