Semaphore
classin packageklyn.threading
public class Semaphore extends Object implements AutoClosable
└ Semaphore
All Implemented Interfaces: 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.

Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public Semaphore
Semaphore(permits as Int = 1)
Creates a semaphore with an initial number of permits.
Methods
Modifier and Type Member Description
public acquire
acquire() as Semaphore
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.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
methodInherited Methods from AutoClosable: close