Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What happens if a thread calls acquire() on a Semaphore and no permits are available?

  1. The thread terminates

  2. The Semaphore's count is reset

  3. The thread proceeds without waiting

  4. The thread is blocked until a permit is available

The correct answer is: The thread is blocked until a permit is available

When a thread calls acquire() on a Semaphore and there are no permits available, the thread is blocked until a permit becomes available. This means that the thread will pause and wait until a permit is released by another thread.