Make the singleton pattern thread-safe