Skip to content

Instantly share code, notes, and snippets.

@sheimi
sheimi / LimitedInstances.java
Created June 23, 2012 14:14 — forked from kavinyao/LimitedInstances.java
A solution to limited instances problem using Proxy Pattern
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
/*
* A solution using Proxy Pattern to limited instances problem
* Requirement:
* class RareResource must have no more than 3 instances at any run time.
* Note:
* Black magic like reflection is out of consideration as you can never prevent it.