本文整理匯總了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();
}