本文整理汇总了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);
}
}
示例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;
}
示例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();
}