Have you ever faced issues with Singleton pattern in multi-threaded applications?
Short answer: Yes. In one project, a singleton was used without thread safety, causing race conditions when accessed concurrently. This led to inconsistent state and application crashes. We resolved it by implementing thread-safe lazy initialization using Lazy<T> in .NET, ensuring the singleton instance was created safely once, even under heavy parallel access.
Real-world example (ShopNest)
ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png