本文整理汇总了Java中java.util.concurrent.AbstractExecutorService类的典型用法代码示例。如果您正苦于以下问题:Java AbstractExecutorService类的具体用法?Java AbstractExecutorService怎么用?Java AbstractExecutorService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractExecutorService类属于java.util.concurrent包,在下文中一共展示了AbstractExecutorService类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: immediateExecutorService
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
private ExecutorService immediateExecutorService() {
return new AbstractExecutorService() {
@Override public void shutdown() {
}
@Override public List<Runnable> shutdownNow() {
return null;
}
@Override public boolean isShutdown() {
return false;
}
@Override public boolean isTerminated() {
return false;
}
@Override public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException {
return false;
}
@Override public void execute(Runnable runnable) {
runnable.run();
}
};
}
示例2: EmptyFunctionBlacklist
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
public EmptyFunctionBlacklist() {
super("EMPTY", new AbstractExecutorService() {
@Override
public void shutdown() {
}
@Override
public List<Runnable> shutdownNow() {
return null;
}
@Override
public boolean isShutdown() {
return true;
}
@Override
public boolean isTerminated() {
return true;
}
@Override
public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException {
return true;
}
@Override
public void execute(final Runnable command) {
}
});
}
示例3: getDefaultExecutorService
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
@Override
protected ExecutorService getDefaultExecutorService() {
if (isMultiThreaded()) {
return super.getDefaultExecutorService();
}
return new AbstractExecutorService() {
boolean terminated;
public void shutdown() {
terminated = true;
}
public List<Runnable> shutdownNow() {
shutdown();
return null;
}
public boolean isShutdown() {
return terminated;
}
public boolean isTerminated() {
return terminated;
}
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException {
shutdown();
return terminated;
}
public void execute(Runnable runnable) {
runnable.run();
}
};
}
示例4: FriendlyCompletionService
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
public FriendlyCompletionService(Executor executor) {
if (executor == null)
throw new NullPointerException();
this.executor = executor;
if (executor instanceof AbstractExecutorService) {
this.aes = (AbstractExecutorService) executor;
} else {
this.aes = null;
}
this.completionQueue = new LinkedBlockingQueue<Future<V>>();
}
示例5: newSynchronousExecutorService
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
/**
* Create an {@link ExecutorService} which runs jobs in main thread.
*/
public static ExecutorService newSynchronousExecutorService() {
return new AbstractExecutorService() {
@Override
public void execute(Runnable command) {
command.run();
}
@Override
public void shutdown() {
throw new UnsupportedOperationException();
}
@Override
public List<Runnable> shutdownNow() {
throw new UnsupportedOperationException();
}
@Override
public boolean isShutdown() {
throw new UnsupportedOperationException();
}
@Override
public boolean isTerminated() {
throw new UnsupportedOperationException();
}
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
throw new UnsupportedOperationException();
}
};
}
示例6: pendClientTask
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
public void pendClientTask(ClientTask task, AbstractExecutorService executor) {
if (sessionCreatedOnServer.get()) {
executor.execute(task);
} else {
synchronized (sessionCreatedOnServer) {
if (sessionCreatedOnServer.get()) {
executor.execute(task);
} else {
pendingTasks.add(task);
}
}
}
}
示例7: onSessionCreatedOnServer
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
public void onSessionCreatedOnServer(AbstractExecutorService executor) {
synchronized (sessionCreatedOnServer) {
if (!sessionCreatedOnServer.get()) {
for (ClientTask task : pendingTasks) {
executor.execute(task);
}
pendingTasks = null;
}
sessionCreatedOnServer.compareAndSet(false, true);
}
}
示例8: ExecutorServiceThreadPool
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
public ExecutorServiceThreadPool(final AbstractExecutorService pool) {
this.pool = pool;
}
示例9: executor
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
@Override
public AbstractExecutorService executor() {
return pool;
}
示例10: wrapExecutor
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
private static ExecutorService wrapExecutor(final Executor executor)
{
return new AbstractExecutorService()
{
private volatile boolean isShutdown = false;
private volatile boolean isTerminated = false;
@Override
public void shutdown()
{
isShutdown = true;
}
@Override
public List<Runnable> shutdownNow()
{
return Lists.newArrayList();
}
@Override
public boolean isShutdown()
{
return isShutdown;
}
@Override
public boolean isTerminated()
{
return isTerminated;
}
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
{
throw new UnsupportedOperationException();
}
@Override
public void execute(Runnable command)
{
try
{
executor.execute(command);
}
finally
{
isShutdown = true;
isTerminated = true;
}
}
};
}
示例11: beforeSuite
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
@BeforeClass
public static void beforeSuite() {
executorContext = Mockito.mock(ExecutorContext.class);
executor = Executors.newSingleThreadScheduledExecutor();
Mockito.when(executorContext.getApiExecutor()).thenReturn(new AbstractExecutorService() {
@Override
public void execute(Runnable command) {
command.run();
}
@Override
public List<Runnable> shutdownNow() {
// TODO Auto-generated method stub
return null;
}
@Override
public void shutdown() {
// TODO Auto-generated method stub
}
@Override
public boolean isTerminated() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isShutdown() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
// TODO Auto-generated method stub
return false;
}
});
Mockito.when(executorContext.getCallbackExecutor()).thenReturn(executor);
Mockito.when(executorContext.getScheduledExecutor()).thenReturn(executor);
}
示例12: TestSession
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
protected TestSession(
final UUID theIdentifier,
final AbstractExecutorService theDelegationExecutorService,
final int bufferSize) {
super(theIdentifier, theDelegationExecutorService, bufferSize);
}
示例13: executor
import java.util.concurrent.AbstractExecutorService; //导入依赖的package包/类
AbstractExecutorService executor();