How do you implement a thread-safe Singleton pattern in C++? Walk me through the code and explain the synchronization mechanism.