public interface Synchronizable
Implementations of this interface expose a lock object
via getLock() so that callers can synchronize
externally on that lock:
if (iterator instanceof Synchronizable)
{
Object element = null;
synchronized (((Synchronizable)iterator).getLock())
{
if (iterator.hasNext())
element = iterator.next();
}
}
In the example above, the calls to hasNext() and
next() are performed "atomically".
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.Object |
getLock() |
Copyright © 1995–2018 Webtide. All rights reserved.