posted 20 years ago
Grin, yeah, I had some things in mind. Object pooling is a pretty well-developed area. The BlockingQueue implementations in JDK 5 are great for this. Here's one possible configuration:
Put 6 instances in the queue at system startup. You can do some tricky stuff to make creation private and control the number, or just trust users to never make their own instances.
Clients do this
Read up on the difference between take and poll, add, put and offer. You can choose to wait, throw exception, etc.
If you're not on JDK 5 yet, the Apache Commons ThreadPool has a nice (simple!) blocking queue you can lift.
Have fun!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi