com.firefly.codec.http2.model.Synchronizable Maven / Gradle / Ivy
The newest version!
package com.firefly.codec.http2.model;
/**
* Implementations of this interface expose a lock object
* via {@link #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 {@code hasNext()} and
* {@code next()} are performed "atomically".
*/
public interface Synchronizable {
/**
* @return the lock object to synchronize on
*/
Object getLock();
}