當前位置: 首頁>>代碼示例>>Java>>正文


Java NotThreadSafe類代碼示例

本文整理匯總了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());
}
 
開發者ID:christian-schlichtherle,項目名稱:truevfs,代碼行數:46,代碼來源:TFileSystem.java


注:本文中的javax.annotation.concurrent.NotThreadSafe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。