FileDocCategorySizeDatePackage
Semaphore.javaAPI DocphoneME MR2 API (J2ME)2298Wed May 02 17:59:54 BST 2007com.sun.cldc.util

Semaphore

public class Semaphore extends Object

Fields Summary
private SemaphoreLock
lock
Constructors Summary
public Semaphore(int permits)
Creates a Semaphore with the given number of permits.

        lock = new SemaphoreLock(permits);
    
Methods Summary
public voidacquire()
Acquires a permit from this semaphore, blocking until one is available.

        lock.acquire();
    
public voidrelease()
Releases a permit, returning it to the semaphore. If any threads are blocking 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.

        lock.release();