A TimeoutSync is an adaptor class that transforms all
calls to acquire to instead invoke attempt with a predetermined
timeout value.
Sample Usage. A TimeoutSync can be used to obtain
Timeouts for locks used in SyncCollections. For example:
Mutex lock = new Mutex();
TimeoutSync timedLock = new TimeoutSync(lock, 1000); // 1 sec timeouts
Set set = new SyncSet(new HashSet(), timedlock);
try {
set. add("hi");
}
// SyncSets translate timeouts and other lock failures
// to unsupported operation exceptions,
catch (UnsupportedOperationException ex) {
System.out.println("Lock failure");
}
[ Introduction to this package. ]
See Also: Sync |