tryIncRef

Expert: increments the refCount of this IndexReader instance only if the IndexReader has not been closed yet and returns true iff the refCount was successfully incremented, otherwise false. If this method returns false the reader is either already closed or is currently being closed. Either way this reader instance shouldn't be used by an application unless true is returned.

RefCounts are used to determine when a reader can be closed safely, i.e. as soon as there are no more references. Be sure to always call a corresponding .decRef, in a finally clause; otherwise the reader may never be closed. Note that .close simply calls decRef(), which means that the IndexReader will not really be closed until .decRef has been called for all outstanding references.

See also

.incRef