001/* 002 * Copyright 2002-2016 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.task; 018 019import java.util.concurrent.Executor; 020 021/** 022 * Simple task executor interface that abstracts the execution 023 * of a {@link Runnable}. 024 * 025 * <p>Implementations can use all sorts of different execution strategies, 026 * such as: synchronous, asynchronous, using a thread pool, and more. 027 * 028 * <p>Equivalent to JDK 1.5's {@link java.util.concurrent.Executor} 029 * interface; extending it now in Spring 3.0, so that clients may declare 030 * a dependency on an Executor and receive any TaskExecutor implementation. 031 * This interface remains separate from the standard Executor interface 032 * mainly for backwards compatibility with JDK 1.4 in Spring 2.x. 033 * 034 * @author Juergen Hoeller 035 * @since 2.0 036 * @see java.util.concurrent.Executor 037 */ 038@FunctionalInterface 039public interface TaskExecutor extends Executor { 040 041 /** 042 * Execute the given {@code task}. 043 * <p>The call might return immediately if the implementation uses 044 * an asynchronous execution strategy, or might block in the case 045 * of synchronous execution. 046 * @param task the {@code Runnable} to execute (never {@code null}) 047 * @throws TaskRejectedException if the given task was not accepted 048 */ 049 @Override 050 void execute(Runnable task); 051 052}