Java 类java.util.concurrent.AbstractExecutorService 实例源码
项目:apollo-android
文件:ApolloWatcherTest.java
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();
}
};
}
项目:FinanceAnalytics
文件:EmptyFunctionBlacklist.java
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) {
}
});
}
项目:DroidDLNA
文件:MockUpnpServiceConfiguration.java
@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();
}
};
}
项目:Factotum
文件:FriendlyCompletionService.java
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>>();
}
项目:Factotum
文件:FriendlyCompletionService.java
public FriendlyCompletionService(Executor executor,
BlockingQueue<Future<V>> completionQueue) {
if (executor == null || completionQueue == null)
throw new NullPointerException();
this.executor = executor;
if (executor instanceof AbstractExecutorService) {
this.aes = (AbstractExecutorService) executor;
} else {
this.aes = null;
}
this.completionQueue = completionQueue;
}
项目:yelp-android
文件:AsyncTestUtils.java
/**
* 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();
}
};
}
项目:Openfire-connectionmanager
文件:ClientSession.java
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);
}
}
}
}
项目:Openfire-connectionmanager
文件:ClientSession.java
public void onSessionCreatedOnServer(AbstractExecutorService executor) {
synchronized (sessionCreatedOnServer) {
if (!sessionCreatedOnServer.get()) {
for (ClientTask task : pendingTasks) {
executor.execute(task);
}
pendingTasks = null;
}
sessionCreatedOnServer.compareAndSet(false, true);
}
}
项目:cyberduck
文件:ExecutorServiceThreadPool.java
public ExecutorServiceThreadPool(final AbstractExecutorService pool) {
this.pool = pool;
}
项目:cyberduck
文件:ExecutorServiceThreadPool.java
@Override
public AbstractExecutorService executor() {
return pool;
}
项目:curator
文件:LeaderSelector.java
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;
}
}
};
}
项目:kaa
文件:DefaultLogCollectorTest.java
@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);
}
项目:omtc
文件:SessionTests.java
protected TestSession(
final UUID theIdentifier,
final AbstractExecutorService theDelegationExecutorService,
final int bufferSize) {
super(theIdentifier, theDelegationExecutorService, bufferSize);
}
项目:cyberduck
文件:ThreadPool.java
AbstractExecutorService executor();