1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
< |
* get returns the last value set or assigned |
62 |
> |
* get returns the last value set or assigned |
63 |
|
*/ |
64 |
|
public void testGetSet() { |
65 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a; |
77 |
|
} |
78 |
|
|
79 |
|
/** |
80 |
< |
* get returns the last value lazySet by same thread |
80 |
> |
* get returns the last value lazySet by same thread |
81 |
|
*/ |
82 |
|
public void testGetLazySet() { |
83 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a; |
94 |
|
assertEquals(-3,a.get(this)); |
95 |
|
} |
96 |
|
|
97 |
– |
|
97 |
|
/** |
98 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
99 |
|
*/ |
109 |
|
assertTrue(a.compareAndSet(this,2,-4)); |
110 |
|
assertEquals(-4,a.get(this)); |
111 |
|
assertFalse(a.compareAndSet(this,-5,7)); |
112 |
< |
assertFalse((7 == a.get(this))); |
112 |
> |
assertEquals(-4,a.get(this)); |
113 |
|
assertTrue(a.compareAndSet(this,-4,7)); |
114 |
|
assertEquals(7,a.get(this)); |
115 |
|
} |
116 |
|
|
118 |
– |
|
117 |
|
/** |
118 |
|
* compareAndSet in one thread enables another waiting for value |
119 |
|
* to succeed |
160 |
|
} |
161 |
|
|
162 |
|
/** |
163 |
< |
* getAndSet returns previous value and sets to given value |
163 |
> |
* getAndSet returns previous value and sets to given value |
164 |
|
*/ |
165 |
|
public void testGetAndSet() { |
166 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a; |
246 |
|
} |
247 |
|
|
248 |
|
/** |
249 |
< |
* decrementAndGet decrements and returns current value |
249 |
> |
* decrementAndGet decrements and returns current value |
250 |
|
*/ |
251 |
|
public void testDecrementAndGet() { |
252 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a; |