net.sf.jabb.util.stat
Class AtomicMaxLong

java.lang.Object
  extended by net.sf.jabb.util.stat.AtomicMaxLong

public class AtomicMaxLong
extends Object

It stores the maximum value; the compare-and-change procedure is synchronized so that multi-thread safe is ensured.
存放最大值,“比较然后交换”的过程是同步的,所以它是多线程安全的。

Author:
Zhengmao HU (James)

Field Summary
protected  Object updateLock
           
protected  long value
           
 
Constructor Summary
AtomicMaxLong()
          Constructs an instance to store the maximum value.
创建一个实例,用来保存最大值。
 
Method Summary
 long get()
          getCurrent value.
获得当前值。
 long getAndMax(long newValue)
          Compare a value with current maximum value and make the greater one the new maximum value; Previous maximum value before comparison is returned.
拿一个值同当前值比较,把其中大的那个设置为新的最大值,返回比较之前的老的最大值。
 int intValue()
          getCurrent value as int.
以int类型获得当前值。
 long longValue()
          getCurrent value.
获得当前值。
 void max(long newValue)
          Compare a value with current maximum value and make the greater one the new maximum value.
拿一个值同当前值比较,把其中大的那个设置为新的最大值。
 long maxAndGet(long newValue)
          Compare a value with current maximum value and make the greater one the new maximum value; New maximum value after comparison is returned.
拿一个值同当前值比较,把其中大的那个设置为新的最大值,返回比较之后的新的最大值。
 void reset()
          Reset to initial status.
回复到初始状态。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected long value

updateLock

protected Object updateLock
Constructor Detail

AtomicMaxLong

public AtomicMaxLong()
Constructs an instance to store the maximum value.
创建一个实例,用来保存最大值。

Method Detail

maxAndGet

public long maxAndGet(long newValue)
Compare a value with current maximum value and make the greater one the new maximum value; New maximum value after comparison is returned.
拿一个值同当前值比较,把其中大的那个设置为新的最大值,返回比较之后的新的最大值。

Parameters:
newValue - 拿来作比较的值。
Returns:
New maximum value after comparison
比较之后的新的最大值

getAndMax

public long getAndMax(long newValue)
Compare a value with current maximum value and make the greater one the new maximum value; Previous maximum value before comparison is returned.
拿一个值同当前值比较,把其中大的那个设置为新的最大值,返回比较之前的老的最大值。

Parameters:
newValue - 拿来作比较的值。
Returns:
Previous maximum value before comparison
比较之前的老的最大值

max

public void max(long newValue)
Compare a value with current maximum value and make the greater one the new maximum value.
拿一个值同当前值比较,把其中大的那个设置为新的最大值。

Parameters:
newValue - 拿来作比较的值。

reset

public void reset()
Reset to initial status.
回复到初始状态。


get

public long get()
getCurrent value.
获得当前值。

Returns:
Current value.

longValue

public long longValue()
getCurrent value.
获得当前值。

Returns:
Current value.

intValue

public int intValue()
getCurrent value as int.
以int类型获得当前值。

Returns:
Current value as int.


Copyright © 2012. All Rights Reserved.