Semaphore
classin packageklyn.threading
public class Semaphore extends Object implements AutoClosable:
Counting semaphore.
`acquire()` blocks until a permit is available and returns an AutoClosable
guard so the permit can be released automatically in a `try` block.
Constructors
| Modifier and Type |
Member |
Description |
| public |
Semaphore |
Creates a semaphore with an initial number of permits. |
Methods
| Modifier and Type |
Member |
Description |
| public |
acquire |
Acquires one permit and returns an AutoClosable guard. |
| public |
close close() as Void:
|
AutoClosable support for try-with-resources. |
| public |
release release() as Void:
|
Releases one permit. |