T
- The type of the iterator.public final class SyncIterator<T> extends Object implements Iterator<T>
Iterator
implementation using a ReadWriteLock
either provided to the constructor or an internally created
ReentrantReadWriteLock
.
The ReadWriteLock
is used to synchronize read calls to
hasNext()
against write calls to
next()
and write calls to any other read or write
calls.
Objects of this class are thread-safe.
Constructor and Description |
---|
SyncIterator(Iterator<T> iterator)
Ctor.
|
SyncIterator(Iterator<T> iterator,
ReadWriteLock lock)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
T |
next() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining, remove
public SyncIterator(Iterator<T> iterator)
iterator
- The iterator to synchronize access to.public SyncIterator(Iterator<T> iterator, ReadWriteLock lock)
iterator
- The iterator to synchronize access to.lock
- The lock to use for synchronization.Copyright © 2017–2019 Cactoos. All rights reserved.