File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/main/java/com/inbravo/concurrency Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
public final class SemaphoreTest {
11
11
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
+ */
13
19
final private Semaphore lock = new Semaphore (1 );
14
20
15
21
/* Change this mode before running the program */
You can’t perform that action at this time.
0 commit comments