Skip to content

Commit fcadebe

Browse files
committed
SemaphoreTest++
SemaphoreTest++
1 parent 311648b commit fcadebe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/inbravo/concurrency/SemaphoreTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
*/
1010
public final class SemaphoreTest {
1111

12-
/* Create new Semaphore object in class */
12+
/*
13+
* The counting semaphore is initialized with a given number of permits (permits = 1 in example)
14+
* For each call to acquire() a permit is taken by the calling thread. For each call to release()
15+
* a permit is returned to the semaphore. Thus, at most N threads can pass the acquire() method
16+
* without any release() calls, where N is the number of permits the semaphore was initialized
17+
* with. The permits are just a simple counter. Nothing fancy here.
18+
*/
1319
final private Semaphore lock = new Semaphore(1);
1420

1521
/* Change this mode before running the program */

0 commit comments

Comments
 (0)