edu.nyu.cs.pdsg.util
Class Semaphore

java.lang.Object
  extended byedu.nyu.cs.pdsg.util.Semaphore

public class Semaphore
extends java.lang.Object

A simple counting semaphore


Field Summary
(package private)  int val
           
 
Constructor Summary
Semaphore()
          Simple initializer, value starts at 0
Semaphore(int _val)
          Full initializer
 
Method Summary
 void p()
          Decrement and potentially lock
 void q()
          Increment and unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

val

volatile int val
Constructor Detail

Semaphore

public Semaphore()
Simple initializer, value starts at 0


Semaphore

public Semaphore(int _val)
Full initializer

Parameters:
_val - The initial value of the semaphore
Method Detail

p

public void p()
Decrement and potentially lock


q

public void q()
Increment and unlock



Copyright (c) 2002-2003 New York University RLAB