Code example for ScheduledThreadPoolExecutor

Methods: executegetQueue

0
    } 
 
    @Override 
    public void execute(Runnable task) {
        if (canScheduleOrExecute()) { 
            delegate.execute(task);
        } else { 
            throw new RejectedExecutionException("Task rejected due queue size limit reached");
        } 
    } 
 
    public void allowCoreThreadTimeOut(boolean value) {
        delegate.allowCoreThreadTimeOut(value);
    } 
 
    public boolean allowsCoreThreadTimeOut() { 
        return delegate.allowsCoreThreadTimeOut();
    } 
 
    /** 
     * Can the task be scheduled or executed? 
     * 
     * @return <tt>true</tt> to accept, <tt>false</tt> to not accept 
     */ 
    protected boolean canScheduleOrExecute() { 
        if (queueSize <= 0) {
            return true; 
        } 
 
        int size = delegate.getQueue().size();
        boolean answer = size < queueSize;
        if (LOG.isTraceEnabled()) { 
            LOG.trace("canScheduleOrExecute {} < {} -> {}", new Object[]{size, queueSize, answer}); 
        } 
        return answer;