fix concurrency issues in random sampler