Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these correctly acquires a permit from a Semaphore?

  • A.sem.acquire();
  • B.sem.lock();
  • C.sem.take();
  • D.sem.enter();

Answer: A

Correct answer: sem.acquire();

Semaphore uses acquire() and release(), and acquire() blocks until a permit is available or the thread is interrupted. tryAcquire() is the non-blocking form. The lock, take and enter vocabularies belong to other types entirely.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.