intermediateSingleton & Object Lifetime46 of 66

Why is storing request-specific mutable state inside a singleton dangerous?

Tests whether you identify that a Singleton's state is shared across all threads/requests, so request-scoped data stored there leaks between unrelated requests under concurrency instead of staying isolated.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Design Patterns & LLD questions