make the implementation threadsafe.