本文整理匯總了Java中javax.annotation.concurrent.NotThreadSafe類的典型用法代碼示例。如果您正苦於以下問題:Java NotThreadSafe類的具體用法?Java NotThreadSafe怎麽用?Java NotThreadSafe使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NotThreadSafe類屬於javax.annotation.concurrent包,在下文中一共展示了NotThreadSafe類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newDirectoryStream
import javax.annotation.concurrent.NotThreadSafe; //導入依賴的package包/類
DirectoryStream<Path> newDirectoryStream(
final TPath path,
final Filter<? super Path> filter)
throws IOException {
final FsNode entry = stat(path);
final Set<String> set;
if (null == entry || null == (set = entry.getMembers()))
throw new NotDirectoryException(path.toString());
@NotThreadSafe
class Adapter implements Iterator<Path> {
final Iterator<String> it = set.iterator();
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public Path next() {
return path.resolve(it.next());
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
} // Adapter
@NotThreadSafe
class FilterIterator extends FilteringIterator<Path> {
FilterIterator() { super(new Adapter()); }
@Override
protected boolean accept(Path element) {
try {
return filter.accept(element);
} catch (IOException ex) {
throw new DirectoryIteratorException(ex);
}
}
} // FilterIterator
return new Stream(new FilterIterator());
}