copy container contents in thread-safe way