Which of the following numbers should you pass to the Release method?

You are busy creating an instance of Semaphore by means of calling its constructor. While the Semaphore instance was created, you specify four resources from a resource pool and reserve the three resources. You want to call the Release method of the Semaphore instance to allocate four available resources from the resource pool. Which of the following numbers should you pass to the Release method?

You are busy creating an instance of Semaphore by means of calling its constructor. While the Semaphore instance was created, you specify four resources from a resource pool and reserve the three resources. You want to call the Release method of the Semaphore instance to allocate four available resources from the resource pool. Which of the following numbers should you pass to the Release method?

A.
3

B.
4

C.
1

D.
0

Explanation:
Every time you call the Release method, the semaphore will exit and makes a resource available. When a parameter has passed to the Release method, you indicate the number of times that the semaphore exits, which is three times.

Incorrect Answers:
B: The SemaphoreFullException can only free three resources in this case.
C: If it was one, then it would have only release one resource.
D: This number would cause an exception of type ArgumentOutOfRangeException to be thrown because the semaphore has to release one resource.



Leave a Reply 0

Your email address will not be published. Required fields are marked *