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.
A 220-litre mixture contains petrol and water, only in ratio 6:5, respectively. How much water should be added in the mixture so that the quantity of wa...
In a 120-litre chemical mixture, the chemicals A and B are in the ratio 5:7. How much of chemical A must be added to make the ratio 7:7 (i.e., equal amo...
An alloy of copper and tin contains 65% of copper. If 12 kg of more tin is added to the alloy, the copper content gets reduced to 50%. Find the quantity...
A vessel contains 300 litres of milk. Each time, x litres of the mixture are replaced with water, and this is done three times. If finally the vessel ha...
A mixture weighing 600 grams consists of sand and cement in a ratio of 3:7. If an additional 20 grams of sand and 80 grams of cement are added to it, wh...
340 ml of mixture contains milk and water in the ratio of 18:x respectively. If 50 ml of water and 60 ml of milk is added into it then ratio of milk to ...
- Two mixtures 'E' and 'F' have gold to silver in the ratio of 7:2 and 9:4 respectively. If 135 grams of E and 182 grams of F are mixed together, then find t...
A tank initially contains a water-alcohol mixture in a 7:3 ratio. After removing 20 liters of the mixture and replacing it with pure alcohol, the ratio ...
Two equal vessels A and B contain 70% of milk and 60% of milk respectively and the remaining sugar. In which 30 kg of mixture is taken out from vessel A...
In a mixture of milk & water, 30 litres water is mixed due to which ratio changes from 3 : 4 to 1 : 2. Find initial quantity of mixture. (in litres)