Package org.apache.lucene.util
Class Counter
- java.lang.Object
-
- org.apache.lucene.util.Counter
-
- Direct Known Subclasses:
Counter.AtomicCounter,Counter.SerialCounter
public abstract class Counter extends java.lang.ObjectSimple counter class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCounter.AtomicCounterprivate static classCounter.SerialCounter
-
Constructor Summary
Constructors Constructor Description Counter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract longaddAndGet(long delta)Adds the given delta to the counters current valueabstract longget()Returns the counters current valuestatic CounternewCounter()Returns a new counter.static CounternewCounter(boolean threadSafe)Returns a new counter.
-
-
-
Method Detail
-
addAndGet
public abstract long addAndGet(long delta)
Adds the given delta to the counters current value- Parameters:
delta- the delta to add- Returns:
- the counters updated value
-
get
public abstract long get()
Returns the counters current value- Returns:
- the counters current value
-
newCounter
public static Counter newCounter()
Returns a new counter. The returned counter is not thread-safe.
-
newCounter
public static Counter newCounter(boolean threadSafe)
Returns a new counter.- Parameters:
threadSafe-trueif the returned counter can be used by multiple threads concurrently.- Returns:
- a new counter.
-
-