jwutil.sync
Class AtomicCounter

java.lang.Object
  extended by jwutil.sync.AtomicCounter

public class AtomicCounter
extends java.lang.Object

An atomic counter class. Provides atomic increment and reset functionality.

Version:
$Id: AtomicCounter.java 2279 2005-05-28 10:24:54Z joewhaley $
Author:
John Whaley

Constructor Summary
AtomicCounter()
          Creates new AtomicCounter, initialized to one.
AtomicCounter(int initialValue)
          Creates new AtomicCounter
 
Method Summary
 int increment()
          Increments this counter, returning the old value.
 void reset(int v)
          Resets this counter to the given value.
 java.lang.String toString()
           
 int value()
          Returns the current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomicCounter

public AtomicCounter(int initialValue)
Creates new AtomicCounter


AtomicCounter

public AtomicCounter()
Creates new AtomicCounter, initialized to one.

Method Detail

increment

public int increment()
Increments this counter, returning the old value.


reset

public void reset(int v)
Resets this counter to the given value.


value

public int value()
Returns the current value.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2008 SUIF Compiler Group. All Rights Reserved.