Threads & Concurrency
Threads are independent paths of execution within a program that allow multiple tasks to run concurrently. Concurrency refers to the ability of a system to make progress on multiple tasks during the same period, often by interleaving execution or using multiple cores. This improves performance, especially in I/O-bound or parallelizable tasks. However, when threads share resources, issues like race conditions can occur, requiring synchronization mechanisms such as locks or semaphores.