The race was in the code displaying the "So far received..." message.
After the check if the counter value modulo 1000000 was zero, the
value actually displayed was queried again, potentially obtaining a
different value (another thread might have incremented the counter).
To force the client to send notifications about garbage collected
objects, the client code forces the GC repeatedly and waits a bit
between the attempts.