当前位置: 首页>>代码示例>>Java>>正文


Java NamedThreadFactory类代码示例

本文整理汇总了Java中com.taobao.tddl.common.utils.thread.NamedThreadFactory的典型用法代码示例。如果您正苦于以下问题:Java NamedThreadFactory类的具体用法?Java NamedThreadFactory怎么用?Java NamedThreadFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamedThreadFactory类属于com.taobao.tddl.common.utils.thread包,在下文中一共展示了NamedThreadFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createThreadPool

import com.taobao.tddl.common.utils.thread.NamedThreadFactory; //导入依赖的package包/类
private ExecutorService createThreadPool(int poolSize, boolean caller) {
    if (caller) {
        return new CallerRunExecutorService();
    } else {
        return new ThreadPoolExecutor(poolSize,
            poolSize,
            0L,
            TimeUnit.MILLISECONDS,
            new ArrayBlockingQueue(poolSize * 2),
            new NamedThreadFactory("tddl_concurrent_query_executor", true),
            new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:14,代码来源:TDataSource.java

示例2: createThreadPool

import com.taobao.tddl.common.utils.thread.NamedThreadFactory; //导入依赖的package包/类
private ThreadPoolExecutor createThreadPool(int poolSize) {
    return new ThreadPoolExecutor(poolSize,
        poolSize,
        0L,
        TimeUnit.MILLISECONDS,
        new ArrayBlockingQueue(poolSize * 2),
        new NamedThreadFactory("tddl_concurrent_query_executor"),
        new ThreadPoolExecutor.CallerRunsPolicy());
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:10,代码来源:TDataSource.java

示例3: buildDataSourceWrapperParallel

import com.taobao.tddl.common.utils.thread.NamedThreadFactory; //导入依赖的package包/类
public static List<DataSourceWrapper> buildDataSourceWrapperParallel(String dsWeightCommaStr,
                                                                     final DataSourceFetcher fetcher) {
    final String[] dsWeightArray = dsWeightCommaStr.split(","); // 逗号分隔:db0:rwp1q1i0,
    // db1:rwp0q0i1
    List<DataSourceWrapper> dss = new ArrayList<DataSourceWrapper>(dsWeightArray.length);

    ThreadPoolExecutor executor = new ThreadPoolExecutor(2,
        2,
        5,
        TimeUnit.SECONDS,
        new LinkedBlockingQueue<Runnable>(),
        new NamedThreadFactory("TDDL_GROUP_INIT"),
        new ThreadPoolExecutor.CallerRunsPolicy());

    Map<String, Future<DataSourceWrapper>> m = new HashMap<String, Future<DataSourceWrapper>>();
    for (int i = 0; i < dsWeightArray.length; i++) {
        final int j = i;
        final String[] dsAndWeight = dsWeightArray[j].split(":"); // 冒号分隔:db0:rwp1q1i0
        final String dsKey = dsAndWeight[0].trim();
        Future<DataSourceWrapper> f = executor.submit(new Callable<DataSourceWrapper>() {

            @Override
            public DataSourceWrapper call() throws Exception {
                String weightStr = dsAndWeight.length == 2 ? dsAndWeight[1] : null;
                return getDataSourceWrapper(dsKey, weightStr, j, fetcher);
            }
        });

        m.put(dsKey, f);
    }

    for (Map.Entry<String, Future<DataSourceWrapper>> en : m.entrySet()) {
        try {
            dss.add(en.getValue().get());
        } catch (Exception e) {
            throw new RuntimeException("init ds error! atom key is " + en.getKey(), e);
        }
    }

    executor.shutdown();
    return dss;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:43,代码来源:GroupConfigManager.java


注:本文中的com.taobao.tddl.common.utils.thread.NamedThreadFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。