Multiple choice technology programming languages

Which Class Limits The Number Of Threads That Can Access A Resource Or Pool Of Resources Concurrently?

  1. Semaphore

  2. Monitor

  3. SynchronizationContext

  4. TimeOut

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A Semaphore (specifically a counting semaphore) is designed to limit the number of threads that can access a resource concurrently. You initialize it with a maximum count, and each thread acquires it (decrementing count) on entry and releases it (incrementing count) on exit. When count reaches zero, additional threads block until others release. Monitors provide mutual exclusion but don't limit concurrent access to a specific number. SynchronizationContext is for marshaling calls to a specific context. Timeout is not a synchronization class.