EDU.oswego.cs.dl.util.concurrent

Class NullSync

Implemented Interfaces:
Sync

public class NullSync
extends Object
implements Sync

A No-Op implementation of Sync. Acquire never blocks, Attempt always succeeds, Release has no effect. However, acquire and release do detect interruption and throw InterruptedException. Also, the methods are synchronized, so preserve memory barrier properties of Syncs.

NullSyncs can be useful in optimizing classes when it is found that locking is not strictly necesssary.

[ Introduction to this package. ]

Fields inherited from interface EDU.oswego.cs.dl.util.concurrent.Sync

ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR

Method Summary

void
acquire()
boolean
attempt(long msecs)
void
release()

Method Details

acquire

public void acquire()
            throws InterruptedException
Specified by:
acquire in interface Sync

attempt

public boolean attempt(long msecs)
            throws InterruptedException
Specified by:
attempt in interface Sync

release

public void release()
Specified by:
release in interface Sync