ゞ沉默是金ゞ

          魚(yú)離不開(kāi)水,但是沒(méi)有說(shuō)不離開(kāi)哪滴水.
          posts - 98,comments - 104,trackbacks - 0
          Today in this article we will see some of threads pool available in “Executors” Factory -
          public static ExecutorService 
                                   newFixedThreadPool(int nThreads)
              Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. At any point, at most nThreads threads will be active processing tasks. If additional tasks are submitted when all threads are active, they will wait in the queue until a thread is available. If any thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks. The threads in the pool will exist until it is explicitly shutdown.

          public static ScheduledExecutorService 
                              newScheduledThreadPool(int corePoolSize)
              Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.

          public static ExecutorService newCachedThreadPool()
          Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. These pools will typically improve the performance of programs that execute many short-lived asynchronous tasks. Calls to execute will reuse previously constructed threads if available. If no existing thread is available, a new thread will be created and added to the pool. Threads that have not been used for sixty seconds are terminated and removed from the cache. Thus, a pool that remains idle for long enough will not consume any resources. Note that pools with similar properties but different details (for example, timeout parameters) may be created using ThreadPoolExecutor constructors.



          public static ExecutorService newSingleThreadExecutor()
              Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks.) Tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time. Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is guaranteed not to be reconfigurable to use additional threads.

          public static ExecutorService newSingleThreadExecutor()
              Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks.) Tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time. Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is guaranteed not to be reconfigurable to use additional threads.
          posted on 2012-08-06 10:41 ゞ沉默是金ゞ 閱讀(786) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Java SE
          主站蜘蛛池模板: 张家港市| 桐柏县| 沂源县| 贞丰县| 南川市| 莲花县| 北碚区| 黔东| 杭锦旗| 三门县| 蒙阴县| 松滋市| 汝州市| 商丘市| 怀化市| 高安市| 建阳市| 靖宇县| 永康市| 通河县| 霍州市| 镇原县| 揭西县| 西乌珠穆沁旗| 防城港市| 秭归县| 晋城| 雅安市| 平和县| 新竹县| 万年县| 尼木县| 庆安县| 赤壁市| 平昌县| 尉犁县| 葵青区| 溧阳市| 休宁县| 龙泉市| 分宜县|