Hi,
I think there is an error with the method compareAndSet in redis Data 2.1.0.
As far as I know this method is atomic, so it cannot be set the value more than once but if you execute the code below it does.
The output of this is:Code:public void testCompareSet() { for (int i = 0; i < 500; i++) { Inner r = new Inner(); new Thread(r).start(); } } private class Inner implements Runnable { @Override public void run() { RedisAtomicInteger atomicInteger = new RedisAtomicInteger("key", redisConnectionFactory); System.out.println(atomicInteger.compareAndSet(0, 1)); } }
false
false
false
false
true
false
false
false
false
false
false
false
false
true
false
false
false
false
true
false
false
false
true
false
false
.......
Am I missing anything?
Thanks


Reply With Quote
