78 |
|
assertEquals(two,a.get(this)); |
79 |
|
a.set(this,m3); |
80 |
|
assertEquals(m3,a.get(this)); |
81 |
– |
|
81 |
|
} |
82 |
+ |
|
83 |
+ |
/** |
84 |
+ |
* get returns the last value lazySet by same thread |
85 |
+ |
*/ |
86 |
+ |
public void testGetLazySet(){ |
87 |
+ |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
88 |
+ |
try { |
89 |
+ |
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
90 |
+ |
} catch (RuntimeException ok) { |
91 |
+ |
return; |
92 |
+ |
} |
93 |
+ |
x = one; |
94 |
+ |
assertEquals(one,a.get(this)); |
95 |
+ |
a.lazySet(this,two); |
96 |
+ |
assertEquals(two,a.get(this)); |
97 |
+ |
a.lazySet(this,m3); |
98 |
+ |
assertEquals(m3,a.get(this)); |
99 |
+ |
} |
100 |
+ |
|
101 |
|
/** |
102 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
103 |
|
*/ |