The Used Key is Always Bright...
Joanne
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
Originally posted by Ernest Friedman-Hill:
In production, if weird stuff happens, you might want to turn it on again to check.
Originally posted by Neelesh A Korade:
Just want to understand the rationale behind using the debug mode only during the development.
Originally posted by Ernest Friedman-Hill:
Pools that work the way you describe are commonly used with things like database connections where there's some reason for only having a finite number, due to limited resources. That isn't the case here.
Originally posted by Ernest Friedman-Hill:
It depends on what the goal is for having a pool is. What you're showing here is going to be S L O W compared to just creating and dropping the objects and letting the GC handle it. I thought the original goal was performance, and this is no way to go after that! The truth is that Sun's GC is optimized for dealing with lots of small short-lived objects, so pools rarely if ever help performance, and often hurt.
If you have a specific need to limit the number of simultaneously existing instances of this class, then you could do something like this; but you have to add some explicit wait() and notify() calls, and be very careful as you code to avoid deadlock, remembering that a call to get an instance might block waiting for any other thread to release one.
Don't get me started about those stupid light bulbs. |