<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Oracle神諭

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      284 隨筆 :: 9 文章 :: 106 評(píng)論 :: 0 Trackbacks

    Package java.util.concurrent(并發(fā)) Description

    Utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious(沉悶的) or difficult to implement. Here are brief(摘要的) descriptions of the main components. See also the locks(鎖) and atomic(原子的) packages.

    Executors(執(zhí)行者)
    Interfaces. Executor is a simple standardized interface for defining custom thread-like subsystems(子系統(tǒng)), including thread pools(線程池), asynchronous IO(異步IO), and lightweight task frameworks(輕量級(jí)任務(wù)框架). Depending on which concrete Executor class is being used, tasks may execute in a newly(以新的方式) created thread, an existing task-execution thread, or the thread calling execute(), and may execute sequentially(繼續(xù)地) or concurrently(并發(fā)地). ExecutorService provides a more complete asynchronous(異步的) task execution framework. An ExecutorService manages queuing(隊(duì)列) and scheduling(行程安排) of tasks, and allows controlled shutdown. The ScheduledExecutorService subinterface adds support for delayed(延時(shí)的) and periodic(定期的) task execution. ExecutorServices provide methods arranging(安排的) asynchronous execution of any function expressed as Callable, the result-bearing analog(類似物) of Runnable. A Future returns the results of a function, allows determination of whether execution has completed, and provides a means to cancel execution.
    Implementations. Classes ThreadPoolExecutor and ScheduledThreadPoolExecutor provide tunable(可調(diào)的), flexible(靈活的) thread pools. The Executors class provides factory methods for the most common kinds and configurations of Executors, as well as a few utility methods for using them. Other utilities based on Executors include the concrete class FutureTask providing a common extensible implementation of Futures, and ExecutorCompletionService, that assists in coordinating(計(jì)算調(diào)配中心) the processing of groups of asynchronous(異步的) tasks.
    [Executor  ExecutorService ScheduledExecutorService ScheduledThreadPoolExecutor ExecutionCompletionService]

    Queues(隊(duì)列)
    The java.util.concurrent ConcurrentLinkedQueue class supplies an efficient scalable(可升級(jí)的) thread-safe(線程安全) non-blocking(非模塊化) FIFO queue. Five implementations in java.util.concurrent support the extended BlockingQueue interface, that defines blocking versions of put and take: LinkedBlockingQueue, ArrayBlockingQueue, SynchronousQueue, PriorityBlockingQueue, and DelayQueue. The different classes cover the most common usage contexts for producer-consumer, messaging, parallel tasking, and related concurrent designs.
    [LinkedBlockingQueue ArrayBlockingQueue SynchronousQueue PriorityBlockingQueue DelayQueue]

    Timing(定時(shí))
    The TimeUnit class provides multiple granularities<間隔尺寸> (including nanoseconds十億分之一秒) for specifying and controlling time-out(暫停) based operations. Most classes in the package contain operations based on time-outs in addition to(除...以外) indefinite(不確定的) waits. In all cases that time-outs are used, the time-out specifies the minimum time that the method should wait before indicating(指出) that it timed-out. Implementations make a "best effort" to detect(察覺) time-outs as soon as possible after they occur. However, an indefinite(模糊的) amount of time may elapse(流逝) between a time-out being detected and a thread actually executing again after that time-out.

    Synchronizers(同步)
    Four classes aid(幫助) common special-purpose synchronization idioms(語法). Semaphore(旗語) is a classic concurrency tool. CountDownLatch(Countdown 倒數(shù)計(jì)秒  latch門插銷) is a very simple yet very common utility for blocking until a given number of signals, events, or conditions hold. A CyclicBarrier(cyclic 循環(huán)的 barrier 屏障) is a resettable(可重置的) multiway(多路的) synchronization point useful in some styles of parallel programming. An Exchanger allows two threads to exchange(交換) objects at a rendezvous point(集合點(diǎn)), and is useful in several pipeline(管道) designs.

    Concurrent Collections(并發(fā)集合)
    Besides Queues, this package supplies a few Collection implementations designed for use in multithreaded contexts: ConcurrentHashMap, CopyOnWriteArrayList, and CopyOnWriteArraySet.
    The "Concurrent" prefix used with some classes in this package is a shorthand(速記) indicating several differences from similar "synchronized" classes. For example java.util.Hashtable and Collections.synchronizedMap(new HashMap()) are synchronized. But ConcurrentHashMap is "concurrent". A concurrent collection is thread-safe, but not governed by a single exclusion lock. In the particular case of ConcurrentHashMap, it safely permits any number of concurrent reads as well as a tunable number of concurrent writes. "Synchronized" classes can be useful when you need to prevent all access to a collection via a single lock, at the expense of poorer scalability. In other cases in which multiple threads are expected to access a common collection, "concurrent" versions are normally preferable. And unsynchronized collections are preferable when either collections are unshared, or are accessible only when holding other locks.

    Most concurrent Collection implementations (including most Queues) also differ from the usual java.util conventions in that their Iterators provide weakly consistent rather than fast-fail traversal. A weakly consistent iterator is thread-safe, but does not necessarily freeze the collection while iterating, so it may (or may not) reflect any updates since the iterator was created.

     

    Since:
    1.5

    posted on 2005-10-08 10:43 java世界暢談 閱讀(910) 評(píng)論(0)  編輯  收藏 所屬分類: JAVA
    主站蜘蛛池模板: 亚洲人成高清在线播放| 亚洲午夜久久影院| 免费一级做a爰片久久毛片潮| 日本片免费观看一区二区| 亚洲国产精品久久66| 2015日韩永久免费视频播放| 亚洲一区二区三区高清| 亚洲一区二区三区免费视频| 亚洲乱码在线视频| 日本特黄特色aa大片免费| 日本亚洲中午字幕乱码| 亚洲国产精品视频| a级精品九九九大片免费看| 亚洲AV无码成人网站久久精品大 | 亚洲黄色网址在线观看| 曰批全过程免费视频网址| 亚洲偷自精品三十六区| 国产裸模视频免费区无码| 九一在线完整视频免费观看| 亚洲小说区图片区另类春色| 精品无码国产污污污免费网站 | 国产成人精品久久亚洲高清不卡 | 亚洲色婷婷一区二区三区| 久久精品免费电影| 国产婷婷综合丁香亚洲欧洲| 国产大片51精品免费观看| 中文字幕免费在线看电影大全| 亚洲国产精品一区| 好男人www免费高清视频在线| 另类专区另类专区亚洲| 亚洲成AV人片在线观看ww| 免费无码AV电影在线观看| 一区二区三区精品高清视频免费在线播放 | 国产99视频免费精品是看6| 国产免费区在线观看十分钟| 亚洲精品欧洲精品| 国产成人啪精品视频免费网| 成人免费区一区二区三区| 日韩亚洲人成在线| 亚洲男人的天堂www| 免费A级毛片无码免费视|