Question
Which design pattern is most suitable for controlling
access to a resource by limiting the number of clients that can use it concurrently?Solution
The Proxy Pattern is a structural design pattern used to control access to resources by acting as an intermediary or placeholder. It can implement restrictions like access control, caching, or logging. In the context of concurrency, the proxy ensures that only a limited number of clients access a resource at a time. For example, a proxy server can manage a pool of database connections, granting access to clients based on availability. This pattern reduces resource contention and improves system scalability and security. By isolating the resource, the Proxy Pattern adds flexibility and control over its usage. Why Other Options Are Incorrect :
- Singleton Pattern : Ensures a single instance of a class but does not control concurrent access.
- Factory Pattern : Focuses on object creation, unrelated to access control.
- Decorator Pattern : Enhances object functionality dynamically but does not manage access.
- Flyweight Pattern : Shares objects to save memory, not for controlling resource access.
Time is taken by two trains running in opposite directions to cross a man standing on the platform in 25 seconds and 15 seconds respectively. It took 18...
The ratio of length to breadth of a rectangle is 8:5. When the length and breadth of the rectangle is increased by 20% and decreased by 30% respectively...
The principle that suggests recording expenses only when they are realized, and income only when they are certain, is known as:
Which of the following statements is correct about 'Shared Economy' ?
In which one of the following places, was Asia's first Export Processing Zone (EPZ) set up in 1965 ?
What fraction of the positions in all panchayat institutions is reserved for women?
Which is illegal as per law?
Who has been appointed as the leader of NASA's newly established initiative "Moon Tour Mars"?
Find the mean deviation of 4,5,6,3,4,8.
The 'Energy Transition Index' is released by