The class org.exolab.jmscts.core.CountingListener
provides access and update operations for the volatile
int _count. _count can be concurrently updated and
accessed by several consumers (like it is the case with
the test SendReceive50Size0KTest). However, in such a
case there isnt any guarantee of whether _count is
atomically updated. A volatile variable state is copied
from global memory to local thread memory and when
modified it is stored back in main memory. But nothing
prevents two threads to read the same value from the
main memory and then concurrently locally update it!
For example this scenario is very likely to happen on a
multi processors box:
_count value is 10
Thread1 reads _count from main memory
Thread2 reads _count from main memory
Thread1 increments _count its local value is now 11.
Thread2 increments _count its local value is now 11.
Thread1 stores _count in main memory
Thread2 stores _count in main memory
_count value is 11 (and not 12 as expected).
The test hangs waiting for a message that has not been
I would like to suggest the following simple workaround:
Add a synchronization statement to the methods
onMessage(Message message) and getReceived() of the
I hope this helps
Log in to post a comment.