public class AtomicBoolean implements java.io.Serializable {
private static final long serialVersionUID = 4654671469794556979L;
// setup to use Unsafe.compareAndSwapInt for updates
public class AtomicBoolean implements java.io.Serializable {
private static final long serialVersionUID = 4654671469794556979L;
// setup to use Unsafe.compareAndSwapInt for updates
valueOffset = unsafe.objectFieldOffset
(AtomicBoolean.class.getDeclaredField("value"));
} catch (Exception ex) { throw new Error(ex); }
valueOffset = unsafe.objectFieldOffset
(AtomicBoolean.class.getDeclaredField("value"));
} catch (Exception ex) { throw new Error(ex); }
- return unsafe.compareAndSwapInt(this, valueOffset, e, u);
+ synchronized (this) {
+ if(e == value) {
+ value = u;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ //return unsafe.compareAndSwapInt(this, valueOffset, e, u);
- return unsafe.compareAndSwapInt(this, valueOffset, e, u);
+ synchronized (this) {
+ if(e == value) {
+ value = u;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ //return unsafe.compareAndSwapInt(this, valueOffset, e, u);*/
* Returns the String representation of the current value.
* @return the String representation of the current value.
*/
* Returns the String representation of the current value.
* @return the String representation of the current value.
*/