Class Semaphore

java.lang.Object
  extended by Semaphore
All Implemented Interfaces:
java.io.Serializable

public class Semaphore
extends java.lang.Object
implements java.io.Serializable

Semaphore. This class is safe against Thread InterruptedException.

Author:
Akitoshi Yoshida, Heinz Kredel.
See Also:
Serialized Form

Field Summary
private  int del
           
private  int init
           
private  int s
           
 
Constructor Summary
Semaphore()
          Constructs a default semaphore.
Semaphore(int i)
          Constructs a semaphore with the given upper limit value.
 
Method Summary
protected  void finalize()
          Finalizes this object.
 boolean isPositive()
          checks if Semaphore is positive.
 void P()
          Performs the P operation.
 boolean P(int m)
          Performs the time limited P operation.
 void V()
          Performs the V operation.
 
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

Semaphore

public Semaphore()
Constructs a default semaphore.


Semaphore

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

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalizes this object.

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

P

public void P()
       throws java.lang.InterruptedException
Performs the P operation.

Throws:
java.lang.InterruptedException

P

public boolean P(int m)
          throws java.lang.InterruptedException
Performs the time limited P operation.

Throws:
java.lang.InterruptedException

V

public void V()
Performs the V operation.


isPositive

public boolean isPositive()
checks if Semaphore is positive.