Share via


Semaphore.Release Method

Definition

Overloads

Release()

Releases a permit, returning it to the semaphore.

Release(Int32)

Releases the given number of permits, returning them to the semaphore.

Release()

Releases a permit, returning it to the semaphore.

[Android.Runtime.Register("release", "()V", "GetReleaseHandler")]
public virtual void Release ();
[<Android.Runtime.Register("release", "()V", "GetReleaseHandler")>]
abstract member Release : unit -> unit
override this.Release : unit -> unit
Attributes

Remarks

Releases a permit, returning it to the semaphore.

Releases a permit, increasing the number of available permits by one. If any threads are trying to acquire a permit, then one is selected and given the permit that was just released. That thread is (re)enabled for thread scheduling purposes.

There is no requirement that a thread that releases a permit must have acquired that permit by calling #acquire. Correct usage of a semaphore is established by programming convention in the application.

Java documentation for java.util.concurrent.Semaphore.release().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Release(Int32)

Releases the given number of permits, returning them to the semaphore.

[Android.Runtime.Register("release", "(I)V", "GetRelease_IHandler")]
public virtual void Release (int permits);
[<Android.Runtime.Register("release", "(I)V", "GetRelease_IHandler")>]
abstract member Release : int -> unit
override this.Release : int -> unit

Parameters

permits
Int32

the number of permits to release

Attributes

Exceptions

if permits is negative

Remarks

Releases the given number of permits, returning them to the semaphore.

Releases the given number of permits, increasing the number of available permits by that amount. If any threads are trying to acquire permits, then one thread is selected and given the permits that were just released. If the number of available permits satisfies that thread's request then that thread is (re)enabled for thread scheduling purposes; otherwise the thread will wait until sufficient permits are available. If there are still permits available after this thread's request has been satisfied, then those permits are assigned in turn to other threads trying to acquire permits.

There is no requirement that a thread that releases a permit must have acquired that permit by calling Semaphore#acquire acquire. Correct usage of a semaphore is established by programming convention in the application.

Java documentation for java.util.concurrent.Semaphore.release(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to