O
Olli Plough
Hello,
I sometimes have a situation that simplified looks like this:
(1) if(aConcurrentNonBlockingCollection.isEmpty())
(2) aAtomicBoolean.getAndSet(true)
Both aConcurrentNonBlockingCollection.isEmpty() and
aAtomicBoolean.getAndSet(true) are atomic and non-blocking using non-
blocking abstract data types from java.util.concurrent. Problem is now
that because of a possible context switch between line (1) and (2) I
end up having to enclose that 2 lines with a lock. Now the lock itself
is not non-blocking and uses synchronized in the end which has much
worse performance characteristics than those non-blocking new ADT in
java.util.concurrent.
Does anybody have an idea how to solve this with the use of non-
blocking synchronization objects? So far I went with
ConcurrentHashMap.putIfAbsent with the use of which I could get round
the problem in some cases. But it sometimes cannot be done this way...
Cheers, Oliver
I sometimes have a situation that simplified looks like this:
(1) if(aConcurrentNonBlockingCollection.isEmpty())
(2) aAtomicBoolean.getAndSet(true)
Both aConcurrentNonBlockingCollection.isEmpty() and
aAtomicBoolean.getAndSet(true) are atomic and non-blocking using non-
blocking abstract data types from java.util.concurrent. Problem is now
that because of a possible context switch between line (1) and (2) I
end up having to enclose that 2 lines with a lock. Now the lock itself
is not non-blocking and uses synchronized in the end which has much
worse performance characteristics than those non-blocking new ADT in
java.util.concurrent.
Does anybody have an idea how to solve this with the use of non-
blocking synchronization objects? So far I went with
ConcurrentHashMap.putIfAbsent with the use of which I could get round
the problem in some cases. But it sometimes cannot be done this way...
Cheers, Oliver