org.logicalcobwebs.concurrent
类 SynchronizedInt

java.lang.Object
  继承者 org.logicalcobwebs.concurrent.SynchronizedVariable
      继承者 org.logicalcobwebs.concurrent.SynchronizedInt
所有已实现的接口:
Cloneable, Comparable, Executor

public class SynchronizedInt
extends SynchronizedVariable
implements Comparable, Cloneable

A class useful for offloading synch for int instance variables.

[ Introduction to this package. ]


字段摘要
protected  int value_
           
 
从类 org.logicalcobwebs.concurrent.SynchronizedVariable 继承的字段
lock_
 
构造方法摘要
SynchronizedInt(int initialValue)
          Make a new SynchronizedInt with the given initial value, and using its own internal lock.
SynchronizedInt(int initialValue, Object lock)
          Make a new SynchronizedInt with the given initial value, and using the supplied lock.
 
方法摘要
 int add(int amount)
          Add amount to value (i.e., set value += amount)
 int and(int b)
          Set value to value & b.
 boolean commit(int assumedValue, int newValue)
          Set value to newValue only if it is currently assumedValue.
 int compareTo(int other)
           
 int compareTo(Object other)
           
 int compareTo(SynchronizedInt other)
           
 int complement()
          Set the value to its complement
 int decrement()
          Decrement the value.
 int divide(int factor)
          Divide value by factor (i.e., set value /= factor)
 boolean equals(Object other)
           
 int get()
          Return the current value
 int hashCode()
           
 int increment()
          Increment the value.
 int multiply(int factor)
          Multiply value by factor (i.e., set value *= factor)
 int negate()
          Set the value to the negative of its old value
 int or(int b)
          Set value to value | b.
 int set(int newValue)
          Set to newValue.
 int subtract(int amount)
          Subtract amount from value (i.e., set value -= amount)
 int swap(SynchronizedInt other)
          Atomically swap values with another SynchronizedInt.
 String toString()
           
 int xor(int b)
          Set value to value ^ b.
 
从类 org.logicalcobwebs.concurrent.SynchronizedVariable 继承的方法
execute, getLock
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

字段详细信息

value_

protected int value_
构造方法详细信息

SynchronizedInt

public SynchronizedInt(int initialValue)
Make a new SynchronizedInt with the given initial value, and using its own internal lock.


SynchronizedInt

public SynchronizedInt(int initialValue,
                       Object lock)
Make a new SynchronizedInt with the given initial value, and using the supplied lock.

方法详细信息

get

public final int get()
Return the current value


set

public int set(int newValue)
Set to newValue.

返回:
the old value

commit

public boolean commit(int assumedValue,
                      int newValue)
Set value to newValue only if it is currently assumedValue.

返回:
true if successful

swap

public int swap(SynchronizedInt other)
Atomically swap values with another SynchronizedInt. Uses identityHashCode to avoid deadlock when two SynchronizedInts attempt to simultaneously swap with each other. (Note: Ordering via identyHashCode is not strictly guaranteed by the language specification to return unique, orderable values, but in practice JVMs rely on them being unique.)

返回:
the new value

increment

public int increment()
Increment the value.

返回:
the new value

decrement

public int decrement()
Decrement the value.

返回:
the new value

add

public int add(int amount)
Add amount to value (i.e., set value += amount)

返回:
the new value

subtract

public int subtract(int amount)
Subtract amount from value (i.e., set value -= amount)

返回:
the new value

multiply

public int multiply(int factor)
Multiply value by factor (i.e., set value *= factor)

返回:
the new value

divide

public int divide(int factor)
Divide value by factor (i.e., set value /= factor)

返回:
the new value

negate

public int negate()
Set the value to the negative of its old value

返回:
the new value

complement

public int complement()
Set the value to its complement

返回:
the new value

and

public int and(int b)
Set value to value & b.

返回:
the new value

or

public int or(int b)
Set value to value | b.

返回:
the new value

xor

public int xor(int b)
Set value to value ^ b.

返回:
the new value

compareTo

public int compareTo(int other)

compareTo

public int compareTo(SynchronizedInt other)

compareTo

public int compareTo(Object other)
指定者:
接口 Comparable 中的 compareTo

equals

public boolean equals(Object other)
覆盖:
Object 中的 equals

hashCode

public int hashCode()
覆盖:
Object 中的 hashCode

toString

public String toString()
覆盖:
Object 中的 toString


Copyright © 2014. All rights reserved.