本文整理了Java中java.util.concurrent.ThreadPoolExecutor.submit()
方法的一些代码示例,展示了ThreadPoolExecutor.submit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.submit()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:submit
暂无
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
/**
* Changes the maximum number of bytes the cache can store and queues a job
* to trim the existing store, if necessary.
*/
public synchronized void setMaxSize(long maxSize) {
this.maxSize = maxSize;
executorService.submit(cleanupCallable);
}
代码示例来源:origin: apache/rocketmq
@Override
public void run() {
ConsumeMessageConcurrentlyService.this.consumeExecutor.submit(consumeRequest);
}
}, 5000, TimeUnit.MILLISECONDS);
代码示例来源:origin: JakeWharton/DiskLruCache
/**
* Changes the maximum number of bytes the cache can store and queues a job
* to trim the existing store, if necessary.
*/
public synchronized void setMaxSize(long maxSize) {
this.maxSize = maxSize;
executorService.submit(cleanupCallable);
}
代码示例来源:origin: Alluxio/alluxio
/**
* Submits a copy task, returns immediately without waiting for completion.
*
* @param task the copy task
*/
public <T> void submit(Callable<T> task) {
mPool.submit(task);
}
代码示例来源:origin: thinkaurelius/titan
public void submit(Runnable runnable) {
processor.submit(runnable);
}
代码示例来源:origin: alibaba/jstorm
public Future<?> submit(Runnable runnable) {
return threadPool.submit(runnable);
}
代码示例来源:origin: apache/hbase
protected Future<Void> submitTask(Callable<Void> task) {
return threadPool.submit(task);
}
代码示例来源:origin: alibaba/jstorm
private synchronized void invokeAll(long flushInterval) {
ArrayList<Flusher> tasks = pendingFlushMap.get(flushInterval);
if (tasks != null) {
for (Flusher f : tasks) {
threadPool.submit(f);
}
}
}
代码示例来源:origin: stagemonitor/stagemonitor
public void waitForCompletion() throws ExecutionException, InterruptedException {
// because the pool is single threaded,
// all previously submitted tasks are completed when this task finishes
asyncRestPool.submit(new Runnable() {
public void run() {
}
}).get();
}
代码示例来源:origin: Netflix/eureka
/* visible for testing */ boolean doWarmUp() {
Future future = null;
try {
future = threadPoolExecutor.submit(updateTask);
future.get(warmUpTimeoutMs, TimeUnit.MILLISECONDS); // block until done or timeout
return true;
} catch (Exception e) {
logger.warn("Best effort warm up failed", e);
} finally {
if (future != null) {
future.cancel(true);
}
}
return false;
}
代码示例来源:origin: stagemonitor/stagemonitor
private void sendBulkAsync(final HttpClient.OutputStreamHandler outputStreamHandler, final boolean logBulkErrors) {
try {
asyncESPool.submit(new Runnable() {
@Override
public void run() {
sendBulk(outputStreamHandler, logBulkErrors);
}
});
} catch (RejectedExecutionException e) {
ExecutorUtils.logRejectionWarning(e);
}
}
代码示例来源:origin: apache/rocketmq
@Override
public void submitConsumeRequest(
final List<MessageExt> msgs,
final ProcessQueue processQueue,
final MessageQueue messageQueue,
final boolean dispathToConsume) {
if (dispathToConsume) {
ConsumeRequest consumeRequest = new ConsumeRequest(processQueue, messageQueue);
this.consumeExecutor.submit(consumeRequest);
}
}
代码示例来源:origin: thinkaurelius/titan
private synchronized void startIDBlockGetter() {
Preconditions.checkArgument(idBlockFuture == null, idBlockFuture);
if (closed) return; //Don't renew anymore if closed
//Renew buffer
log.debug("Starting id block renewal thread upon {}", currentIndex);
idBlockGetter = new IDBlockGetter(idAuthority, partition, idNamespace, renewTimeout);
idBlockFuture = exec.submit(idBlockGetter);
}
代码示例来源:origin: org.testng/testng
@Override
public IFutureResult submitRunnable(final Runnable runnable) {
return new FutureResultAdapter(super.submit(runnable));
}
代码示例来源:origin: Alluxio/alluxio
@Override
public void process(AlluxioURI path, List<Inode> prefixInodes) {
mPool.submit(new ProcessPathTask(path, prefixInodes));
}
代码示例来源:origin: JanusGraph/janusgraph
private synchronized void startIDBlockGetter() {
Preconditions.checkArgument(idBlockFuture == null, idBlockFuture);
if (closed) return; //Don't renew anymore if closed
//Renew buffer
log.debug("Starting id block renewal thread upon {}", currentIndex);
idBlockGetter = new IDBlockGetter(idAuthority, partition, idNamespace, renewTimeout);
idBlockFuture = exec.submit(idBlockGetter);
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Allocate instance to a process and return. This call blocks until item
* can be assigned to a thread.
*
* @param item Input to a Processor
* @throws RejectedExecutionException -- A RuntimeException when there is an
* uncaught exception in the queue. Resolution is for the calling class to shutdown
* the wrapper and create a new threadpool.
*
*/
public synchronized void put(I item) throws RejectedExecutionException {
Integer procId = getProcessor();
if (procId == null) {
throw new RejectedExecutionException("Couldn't submit item to threadpool: " + item);
}
final int itemId = submittedItemCounter++;
CallableJob<I,O> job = new CallableJob<>(item, itemId, processorList.get(procId), procId, callback);
threadPool.submit(job);
}
代码示例来源:origin: h2oai/h2o-2
@SuppressWarnings("rawtypes")
public Future<GoogleAnalyticsResponse> postAsync(final GoogleAnalyticsRequest request) {
if (!config.isEnabled()) {
return null;
}
Future<GoogleAnalyticsResponse> future = getExecutor().submit(new Callable<GoogleAnalyticsResponse>() {
public GoogleAnalyticsResponse call() throws Exception {
return post(request);
}
});
return future;
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test(expected = RejectedExecutionException.class)
public void testRejectedExecution() throws Exception {
for (int i = 0; i < 10; i++) {
lowCapacityPool.submit(sleepABit);
}
}
}
代码示例来源:origin: PipelineAI/pipeline
@Override
public Subscription schedule(final Action0 action) {
if (subscription.isUnsubscribed()) {
// don't schedule, we are unsubscribed
return Subscriptions.unsubscribed();
}
// This is internal RxJava API but it is too useful.
ScheduledAction sa = new ScheduledAction(action);
subscription.add(sa);
sa.addParent(subscription);
ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor();
FutureTask<?> f = (FutureTask<?>) executor.submit(sa);
sa.add(new FutureCompleterWithConfigurableInterrupt(f, shouldInterruptThread, executor));
return sa;
}
内容来源于网络,如有侵权,请联系作者删除!