Concurrency fix for example in "Count number of hosts by application group"

When the previous code was called concurrently old values might be applied instead of changing the value atomically.
Merge pull request #256 from jeroenvandijk/patch-2

Concurrency fix for example in "Count number of hosts by application gro...