279 assertEquals(success, true, "weakCompareAndSwapRelease int"); |
279 assertEquals(success, true, "weakCompareAndSwapRelease int"); |
280 int x = UNSAFE.getInt(base, offset); |
280 int x = UNSAFE.getInt(base, offset); |
281 assertEquals(x, 2, "weakCompareAndSwapRelease int"); |
281 assertEquals(x, 2, "weakCompareAndSwapRelease int"); |
282 } |
282 } |
283 |
283 |
|
284 { |
|
285 boolean success = false; |
|
286 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
287 success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 2, 1); |
|
288 } |
|
289 assertEquals(success, true, "weakCompareAndSwapVolatile int"); |
|
290 int x = UNSAFE.getInt(base, offset); |
|
291 assertEquals(x, 1, "weakCompareAndSwapVolatile int"); |
|
292 } |
|
293 |
|
294 UNSAFE.putInt(base, offset, 2); |
|
295 |
284 // Compare set and get |
296 // Compare set and get |
285 { |
297 { |
286 int o = UNSAFE.getAndSetInt(base, offset, 1); |
298 int o = UNSAFE.getAndSetInt(base, offset, 1); |
287 assertEquals(o, 2, "getAndSet int"); |
299 assertEquals(o, 2, "getAndSet int"); |
288 int x = UNSAFE.getInt(base, offset); |
300 int x = UNSAFE.getInt(base, offset); |