Class Sema

java.lang.Object
  extended by Sema

public class Sema
extends java.lang.Object

Semaphore. This class implements a semaphore.

Author:
Akitoshi Yoshida, Heinz Kredel.

Field Summary
private  int del
           
private  int init
           
private  int s
           
 
Constructor Summary
Sema()
          Constructs a default semaphore.
Sema(int i)
          Constructs a semaphore with the given upper limit value.
 
Method Summary
protected  void finalize()
          Releases the ressources of the constructed semaphore.
 boolean isPositive()
          checks if Semaphore is positive.
 void P()
          Performs the P operation, which causes the current thread to wait until the semaphore is positive.
 void V()
          The V operation increases the value of s.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

init

private int init

s

private int s

del

private int del
Constructor Detail

Sema

public Sema()
Constructs a default semaphore.


Sema

public Sema(int i)
Constructs a semaphore with the given upper limit value.

Parameters:
i - limit.
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Releases the ressources of the constructed semaphore.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

P

public void P()
Performs the P operation, which causes the current thread to wait until the semaphore is positive.


V

public void V()
The V operation increases the value of s.


isPositive

public boolean isPositive()
checks if Semaphore is positive.