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


Java Util.threadFactory方法代码示例

本文整理汇总了Java中com.squareup.okhttp.internal.Util.threadFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Util.threadFactory方法的具体用法?Java Util.threadFactory怎么用?Java Util.threadFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.internal.Util的用法示例。


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

示例1: ConnectionPool

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
public ConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) {
    this.executor = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new
            LinkedBlockingQueue(), Util.threadFactory("OkHttp ConnectionPool", true));
    this.cleanupRunnable = new Runnable() {
        public void run() {
            while (true) {
                long waitNanos = ConnectionPool.this.cleanup(System.nanoTime());
                if (waitNanos != -1) {
                    if (waitNanos > 0) {
                        long waitMillis = waitNanos / 1000000;
                        waitNanos -= waitMillis * 1000000;
                        synchronized (ConnectionPool.this) {
                            try {
                                ConnectionPool.this.wait(waitMillis, (int) waitNanos);
                            } catch (InterruptedException e) {
                            }
                        }
                    }
                } else {
                    return;
                }
            }
        }
    };
    this.connections = new ArrayDeque();
    this.routeDatabase = new RouteDatabase();
    this.maxIdleConnections = maxIdleConnections;
    this.keepAliveDurationNs = timeUnit.toNanos(keepAliveDuration);
    if (keepAliveDuration <= 0) {
        throw new IllegalArgumentException("keepAliveDuration <= 0: " + keepAliveDuration);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:ConnectionPool.java

示例2: getExecutorService

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
public synchronized ExecutorService getExecutorService() {
    if (this.executorService == null) {
        this.executorService = new ThreadPoolExecutor(0, ActivityChooserViewAdapter
                .MAX_ACTIVITY_COUNT_UNLIMITED, 60, TimeUnit.SECONDS, new SynchronousQueue(),
                Util.threadFactory("OkHttp Dispatcher", false));
    }
    return this.executorService;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:Dispatcher.java

示例3: FramedConnection

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
private FramedConnection(Builder builder) throws IOException {
    int i = 2;
    this.streams = new HashMap();
    this.idleStartTimeNs = System.nanoTime();
    this.unacknowledgedBytesRead = 0;
    this.okHttpSettings = new Settings();
    this.peerSettings = new Settings();
    this.receivedInitialPeerSettings = false;
    this.currentPushRequests = new LinkedHashSet();
    this.protocol = builder.protocol;
    this.pushObserver = builder.pushObserver;
    this.client = builder.client;
    this.listener = builder.listener;
    this.nextStreamId = builder.client ? 1 : 2;
    if (builder.client && this.protocol == Protocol.HTTP_2) {
        this.nextStreamId += 2;
    }
    if (builder.client) {
        i = 1;
    }
    this.nextPingId = i;
    if (builder.client) {
        this.okHttpSettings.set(7, 0, 16777216);
    }
    this.hostName = builder.hostName;
    if (this.protocol == Protocol.HTTP_2) {
        this.variant = new Http2();
        this.pushExecutor = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new
                LinkedBlockingQueue(), Util.threadFactory(String.format("OkHttp %s Push " +
                "Observer", new Object[]{this.hostName}), true));
        this.peerSettings.set(7, 0, 65535);
        this.peerSettings.set(5, 0, 16384);
    } else if (this.protocol == Protocol.SPDY_3) {
        this.variant = new Spdy3();
        this.pushExecutor = null;
    } else {
        throw new AssertionError(this.protocol);
    }
    this.bytesLeftInWriteWindow = (long) this.peerSettings.getInitialWindowSize(65536);
    this.socket = builder.socket;
    this.frameWriter = this.variant.newWriter(builder.sink, this.client);
    this.readerRunnable = new Reader(this.variant.newReader(builder.source, this.client));
    new Thread(this.readerRunnable).start();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:45,代码来源:FramedConnection.java


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