75 |
|
* get returns the last value set or assigned |
76 |
|
*/ |
77 |
|
public void testGetSet() { |
78 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
78 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
79 |
|
a = updaterFor("x"); |
80 |
|
x = one; |
81 |
|
assertSame(one, a.get(this)); |
89 |
|
* get returns the last value lazySet by same thread |
90 |
|
*/ |
91 |
|
public void testGetLazySet() { |
92 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
92 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
93 |
|
a = updaterFor("x"); |
94 |
|
x = one; |
95 |
|
assertSame(one, a.get(this)); |
103 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
104 |
|
*/ |
105 |
|
public void testCompareAndSet() { |
106 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
106 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
107 |
|
a = updaterFor("x"); |
108 |
|
x = one; |
109 |
|
assertTrue(a.compareAndSet(this, one, two)); |
121 |
|
*/ |
122 |
|
public void testCompareAndSetInMultipleThreads() throws Exception { |
123 |
|
x = one; |
124 |
< |
final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
124 |
> |
final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
125 |
|
a = updaterFor("x"); |
126 |
|
|
127 |
|
Thread t = new Thread(new CheckedRunnable() { |
142 |
|
* to expected |
143 |
|
*/ |
144 |
|
public void testWeakCompareAndSet() { |
145 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
145 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
146 |
|
a = updaterFor("x"); |
147 |
|
x = one; |
148 |
|
do {} while (!a.weakCompareAndSet(this, one, two)); |
156 |
|
* getAndSet returns previous value and sets to given value |
157 |
|
*/ |
158 |
|
public void testGetAndSet() { |
159 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
159 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a; |
160 |
|
a = updaterFor("x"); |
161 |
|
x = one; |
162 |
|
assertSame(one, a.getAndSet(this, zero)); |