PCAP Object-Oriented Programming • Set 9
PCAP Object-Oriented Programming Practice Test 9 — 15 questions with explanations. Free, no signup.
A junior developer writes a class 'Logger' that should only ever have one instance (singleton). They attempt to implement it by overriding __new__ to always return the same instance. However, when multiple threads attempt to create a Logger, they sometimes get different instances. Which modification will make the singleton thread-safe?