Access to queue is fully synchronized -- meaning that all methods are synchronized by implementations as necessary, and caller should not need to use external synchronization -- since parts will have to be anyway (updating of stats, pointers), and since all real-world use cases will need some level of synchronization anyway, even with just single producer and consumer. If it turns out that there are bottlenecks that could be avoided with more granular (or external) locking, this design can be revisited.
Note that if instances are discarded, they MUST be closed: finalize() method is not implemented since it is both somewhat unreliable (i.e. should not be counted on) and can add overhead for GC processing.
|
|