欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

目錄

柚子快報(bào)邀請(qǐng)碼778899分享:ribbon源碼中線程是的使用

柚子快報(bào)邀請(qǐng)碼778899分享:ribbon源碼中線程是的使用

http://yzkb.51969.com/

源碼類(lèi):PollingServerListUpdater

使用單例模式(靜態(tài)內(nèi)部類(lèi)),初始化線程池

//使用靜態(tài)內(nèi)部類(lèi)初始化線程池

private static class LazyHolder {

private final static String CORE_THREAD = "DynamicServerListLoadBalancer.ThreadPoolSize";

private final static DynamicIntProperty poolSizeProp = new DynamicIntProperty(CORE_THREAD, 2);

private static Thread _shutdownThread;

static ScheduledThreadPoolExecutor _serverListRefreshExecutor = null;

static {

int coreSize = poolSizeProp.get();

ThreadFactory factory = (new ThreadFactoryBuilder())

.setNameFormat("PollingServerListUpdater-%d")

.setDaemon(true)

.build();

//創(chuàng)建線程池

_serverListRefreshExecutor = new ScheduledThreadPoolExecutor(coreSize, factory);

poolSizeProp.addCallback(new Runnable() {

@Override

public void run() {

_serverListRefreshExecutor.setCorePoolSize(poolSizeProp.get());

}

});

_shutdownThread = new Thread(new Runnable() {

public void run() {

logger.info("Shutting down the Executor Pool for PollingServerListUpdater");

//關(guān)閉線程池

shutdownExecutorPool();

}

});

//虛擬機(jī)關(guān)閉鉤子方法

Runtime.getRuntime().addShutdownHook(_shutdownThread);

}

private static void shutdownExecutorPool() {

if (_serverListRefreshExecutor != null) {

//關(guān)閉線程池

_serverListRefreshExecutor.shutdown();

if (_shutdownThread != null) {

try {

//關(guān)閉線程

Runtime.getRuntime().removeShutdownHook(_shutdownThread);

} catch (IllegalStateException ise) { // NOPMD

// this can happen if we're in the middle of a real

// shutdown,

// and that's 'ok'

}

}

}

}

}

//獲取線程池實(shí)例

private static ScheduledThreadPoolExecutor getRefreshExecutor() {

return LazyHolder._serverListRefreshExecutor;

}

柚子快報(bào)邀請(qǐng)碼778899分享:ribbon源碼中線程是的使用

http://yzkb.51969.com/

相關(guān)閱讀

評(píng)論可見(jiàn),查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。

轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/18721550.html

發(fā)布評(píng)論

您暫未設(shè)置收款碼

請(qǐng)?jiān)谥黝}配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問(wèn)

文章目錄