thread safe sampling