當前位置: 首頁>>代碼示例>>Java>>正文


Java RejectedExecutionException類代碼示例

本文整理匯總了Java中java.util.concurrent.RejectedExecutionException的典型用法代碼示例。如果您正苦於以下問題:Java RejectedExecutionException類的具體用法?Java RejectedExecutionException怎麽用?Java RejectedExecutionException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RejectedExecutionException類屬於java.util.concurrent包,在下文中一共展示了RejectedExecutionException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: submitListenable

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@Override
public ListenableFuture<?> submitListenable (Runnable task)
{
   ExecutorService executor = getThreadPoolExecutor ();
   try
   {
      ListenableFutureTask<Object> future =
         new ListenableFutureTask<Object> (task, null);
      executor.execute (future);
      return future;
   }
   catch (RejectedExecutionException ex)
   {
      throw new TaskRejectedException ("Executor [" + executor +
         "] did not accept task: " + task, ex);
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:18,代碼來源:FairThreadPoolTaskExecutor.java

示例2: processRpcRequest

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
/**處理客戶端請求**/
private void processRpcRequest(final ChannelHandlerContext context, final DefaultRequest request) {
    final long processStartTime = System.currentTimeMillis();
    try {
        this.pool.execute(new Runnable() {
            @Override
            public void run() {

                try {
                    RpcContext.init(request);
                    processRpcRequest(context, request, processStartTime);
                } finally {
                    RpcContext.destroy();
                }

            }
        });
    } catch (RejectedExecutionException e) {
        DefaultResponse response = new DefaultResponse();
        response.setRequestId(request.getRequestId());
        response.setException(new RpcFrameworkException("process thread pool is full, reject"));
        response.setProcessTime(System.currentTimeMillis() - processStartTime);
        context.channel().write(response);
    }

}
 
開發者ID:TFdream,項目名稱:mango,代碼行數:27,代碼來源:NettyServerImpl.java

示例3: execute

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
/**
 * Submit a task to be executed in the future.
 * @param runnable The task to be executed.
 */
@Override
public void execute(Runnable runnable) {
  if (runnable == null) {
    throw new NullPointerException("runnable parameter is null");
  }

  if (!mWorkQueue.offer(runnable)) {
    throw new RejectedExecutionException(
        mName + " queue is full, size=" + mWorkQueue.size());
  }

  final int queueSize = mWorkQueue.size();
  final int maxSize = mMaxQueueSize.get();
  if ((queueSize > maxSize) && mMaxQueueSize.compareAndSet(maxSize, queueSize)) {
    FLog.v(TAG, "%s: max pending work in queue = %d", mName, queueSize);
  } // else, there was a race and another thread updated and logged the max queue size

  startWorkerIfNeeded();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:ConstrainedExecutorService.java

示例4: execute

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
public void execute(ReceivablePacket<L2GameClient> rp)
{
	try
	{
		if (rp.getClient().getState() == GameClientState.IN_GAME)
		{
			ThreadPoolManager.getInstance().executePacket(rp);
		}
		else
		{
			ThreadPoolManager.getInstance().executeIOPacket(rp);
		}
	}
	catch (RejectedExecutionException e)
	{
		// if the server is shutdown we ignore
		if (!ThreadPoolManager.getInstance().isShutdown())
		{
			_log.severe("Failed executing: "+rp.getClass().getSimpleName()+" for Client: "+rp.getClient().toString());
		}
	}
}
 
開發者ID:L2jBrasil,項目名稱:L2jBrasil,代碼行數:23,代碼來源:L2GamePacketHandler.java

示例5: endpointNowInUse

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@Override
public void endpointNowInUse(Endpoint endpoint) {
  int count = endpointCount.incrementAndGet();
  final boolean isDebugEnabled = logger.isDebugEnabled();
  if (isDebugEnabled) {
    logger.debug("InstantiatorRecoveryTask - EndpointNowInUse. Now have {} endpoints", count);
  }
  if (count == 1) {
    synchronized (recoveryScheduledLock) {
      if (!recoveryScheduled) {
        try {
          recoveryScheduled = true;
          background.execute(new RecoveryTask());
          if (isDebugEnabled) {
            logger.debug("InstantiatorRecoveryTask - Scheduled Recovery Task");
          }
        } catch (RejectedExecutionException e) {
          // ignore, the timer has been cancelled, which means we're shutting down.
        }
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:24,代碼來源:InstantiatorRecoveryListener.java

示例6: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
	if (!stopped && outstandingTask == null) {
		AutoFocusTask newTask = new AutoFocusTask();
		try {
			// Unnecessary, our app's min sdk is higher than 11.
			// if (Build.VERSION.SDK_INT >= 11) {
			// 	newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			// } else {
			//
			// }
			newTask.execute();
			outstandingTask = newTask;
		} catch (RejectedExecutionException ree) {
			Log.w(TAG, "Could not request auto focus", ree);
		}
	}
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:19,代碼來源:AutoFocusManager.java

示例7: basicProcess

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
/** Return true if a reply should be sent */
@Override
protected void basicProcess(final DistributionManager dm, final LocalRegion lclRgn) {
  Assert.assertTrue(this.serialNum != DistributionAdvisor.ILLEGAL_SERIAL);
  try {
    this.lockRoot = null;
    // may set lockRoot to the root region where destroyLock is acquired

    final boolean sendReply = true;

    // Part of fix for bug 34450 which was caused by a PR destroy region op
    // dead-locked with
    // a PR create region op. The create region op required an entry update
    // to release a
    // DLock needed by the PR destroy.. by moving the destroy to the waiting
    // pool, the entry
    // update is allowed to complete.
    dm.getWaitingThreadPool().execute(destroyOp(dm, lclRgn, sendReply));
  } catch (RejectedExecutionException e) {
    // rejected while trying to execute destroy thread
    // must be shutting down, just quit
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:24,代碼來源:DestroyRegionOperation.java

示例8: submit

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@Override
public RExecutorBatchFuture submit(Callable<?> ...tasks) {
    if (tasks.length == 0) {
        throw new NullPointerException("Tasks are not defined");
    }

    List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
    TasksBatchService executorRemoteService = createBatchService();
    RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
    for (Callable<?> task : tasks) {
        check(task);
        byte[] classBody = getClassBody(task);
        byte[] state = encode(task);
        RemotePromise<?> promise = (RemotePromise<?>)asyncService.executeCallable(task.getClass().getName(), classBody, state);
        RedissonExecutorFuture<?> executorFuture = new RedissonExecutorFuture(promise, promise.getRequestId());
        result.add(executorFuture);
    }
    
    List<Boolean> addResult = (List<Boolean>) executorRemoteService.executeAdd();
    if (!addResult.get(0)) {
        throw new RejectedExecutionException("Tasks have been rejected. ExecutorService is in shutdown state");
    }
    
    return new RedissonExecutorBatchFuture(result);
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:26,代碼來源:RedissonExecutorService.java

示例9: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@SuppressLint("NewApi")
synchronized void autoFocusAgainLater() {
	if (!stopped && outstandingTask == null) {
		AutoFocusTask newTask = new AutoFocusTask();
		try {
			if (Build.VERSION.SDK_INT >= 11) {
				newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				newTask.execute();
			}
			outstandingTask = newTask;
		} catch (RejectedExecutionException ree) {
			Log.w(TAG, "Could not request auto focus", ree);
		}
	}
}
 
開發者ID:AnyRTC,項目名稱:anyRTC-RTCP-Android,代碼行數:17,代碼來源:AutoFocusManager.java

示例10: growArray

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
/**
 * Initializes or doubles the capacity of array. Call either
 * by owner or with lock held -- it is OK for base, but not
 * top, to move while resizings are in progress.
 */
final ForkJoinTask<?>[] growArray() {
    ForkJoinTask<?>[] oldA = array;
    int size = oldA != null ? oldA.length << 1 : INITIAL_QUEUE_CAPACITY;
    if (size > MAXIMUM_QUEUE_CAPACITY)
        throw new RejectedExecutionException("Queue capacity exceeded");
    int oldMask, t, b;
    ForkJoinTask<?>[] a = array = new ForkJoinTask<?>[size];
    if (oldA != null && (oldMask = oldA.length - 1) >= 0 &&
        (t = top) - (b = base) > 0) {
        int mask = size - 1;
        do { // emulate poll from old array, push to new array
            ForkJoinTask<?> x;
            int oldj = ((b & oldMask) << ASHIFT) + ABASE;
            int j    = ((b &    mask) << ASHIFT) + ABASE;
            x = (ForkJoinTask<?>)U.getObjectVolatile(oldA, oldj);
            if (x != null &&
                U.compareAndSwapObject(oldA, oldj, x, null))
                U.putObjectVolatile(a, j, x);
        } while (++b != t);
    }
    return a;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:ForkJoinPool.java

示例11: growArray

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
/**
 * Initializes or doubles the capacity of array. Call either
 * by owner or with lock held -- it is OK for base, but not
 * top, to move while resizings are in progress.
 */
final ForkJoinTask<?>[] growArray() {
    ForkJoinTask<?>[] oldA = array;
    int size = oldA != null ? oldA.length << 1 : INITIAL_QUEUE_CAPACITY;
    if (size > MAXIMUM_QUEUE_CAPACITY)
        throw new RejectedExecutionException("Queue capacity exceeded");
    int oldMask, t, b;
    ForkJoinTask<?>[] a = array = new ForkJoinTask<?>[size];
    if (oldA != null && (oldMask = oldA.length - 1) >= 0 &&
        (t = top) - (b = base) > 0) {
        int mask = size - 1;
        do {
            ForkJoinTask<?> x;
            int oldj = ((b & oldMask) << ASHIFT) + ABASE;
            int j    = ((b &    mask) << ASHIFT) + ABASE;
            x = (ForkJoinTask<?>)U.getObjectVolatile(oldA, oldj);
            if (x != null &&
                U.compareAndSwapObject(oldA, oldj, x, null))
                U.putObjectVolatile(a, j, x);
        } while (++b != t);
    }
    return a;
}
 
開發者ID:monix,項目名稱:monix-forkjoin,代碼行數:28,代碼來源:ForkJoinPool.java

示例12: addFailure

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
public void addFailure() {
  if (blacklist.contains(location)) {
    // A second failure must have happened before we added
    // this server to the blacklist. Don't count that failure.
    return;
  }
  long failures = consecutiveFailures.incrementAndGet();
  if (failures >= THRESHOLD) {
    if (logger.isDebugEnabled()) {
      logger.debug("Blacklisting server {} for {}ms because it had {} consecutive failures",
          location, pingInterval, failures);
    }
    blacklist.add(location);
    broadcaster.serverAdded(location);
    try {
      background.schedule(new ExpireBlackListTask(location), pingInterval,
          TimeUnit.MILLISECONDS);
    } catch (RejectedExecutionException e) {
      // ignore, the timer has been cancelled, which means we're shutting down.
    }

  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:24,代碼來源:ServerBlackList.java

示例13: schedule

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
public Subscription schedule(Action0 action) {
    if (isUnsubscribed()) {
        return Subscriptions.unsubscribed();
    }
    Subscription ea = new ScheduledAction(action, this.tasks);
    this.tasks.add(ea);
    this.queue.offer(ea);
    if (this.wip.getAndIncrement() != 0) {
        return ea;
    }
    try {
        this.executor.execute(this);
        return ea;
    } catch (RejectedExecutionException t) {
        this.tasks.remove(ea);
        this.wip.decrementAndGet();
        RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
        throw t;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:ExecutorScheduler.java

示例14: processSocket

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
public boolean processSocket(NioChannel socket, SocketStatus status, boolean dispatch) {
    try {
        KeyAttachment attachment = (KeyAttachment)socket.getAttachment();
        if (attachment == null) {
            return false;
        }
        attachment.setCometNotify(false); //will get reset upon next reg
        SocketProcessor sc = processorCache.poll();
        if ( sc == null ) sc = new SocketProcessor(socket,status);
        else sc.reset(socket,status);
        if ( dispatch && getExecutor()!=null ) getExecutor().execute(sc);
        else sc.run();
    } catch (RejectedExecutionException rx) {
        log.warn("Socket processing request was rejected for:"+socket,rx);
        return false;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        // This means we got an OOM or similar creating a thread, or that
        // the pool and its queue are full
        log.error(sm.getString("endpoint.process.fail"), t);
        return false;
    }
    return true;
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:25,代碼來源:NioEndpoint.java

示例15: autoFocusAgainLater

import java.util.concurrent.RejectedExecutionException; //導入依賴的package包/類
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
    if (!stopped && outstandingTask == null) {
        AutoFocusTask newTask = new AutoFocusTask();
        try {
            if (Build.VERSION.SDK_INT >= 11) {
                newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                newTask.execute();
            }
            outstandingTask = newTask;
        } catch (RejectedExecutionException ree) {
            Log.w(TAG, "Could not request auto focus", ree);
        }
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:17,代碼來源:AutoFocusManager.java


注:本文中的java.util.concurrent.RejectedExecutionException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。