1 /* 2 * Copyright 2002-2007 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.core.task; 18 19 /** 20 * Extended interface for asynchronous {@link TaskExecutor} implementations, 21 * offering an overloaded {@link #execute(Runnable, long)} variant with 22 * start timeout parameter. 23 * 24 * <p>Implementing this interface also indicates that the {@link #execute(Runnable)} 25 * method will not execute its Runnable in the caller's thread but rather 26 * asynchronously in some other thread (at least usually). 27 * 28 * @author Juergen Hoeller 29 * @since 2.0.3 30 * @see SimpleAsyncTaskExecutor 31 * @see org.springframework.scheduling.SchedulingTaskExecutor 32 */ 33 public interface AsyncTaskExecutor extends TaskExecutor { 34 35 /** Constant that indicates immediate execution */ 36 long TIMEOUT_IMMEDIATE = 0; 37 38 /** Constant that indicates no time limit */ 39 long TIMEOUT_INDEFINITE = Long.MAX_VALUE; 40 41 42 /** 43 * Execute the given <code>task</code>. 44 * @param task the <code>Runnable</code> to execute (never <code>null</code>) 45 * @param startTimeout the time duration within which the task is supposed to start. 46 * This is intended as a hint to the executor, allowing for preferred handling 47 * of immediate tasks. Typical values are {@link #TIMEOUT_IMMEDIATE} or 48 * {@link #TIMEOUT_INDEFINITE} (the default as used by {@link #execute(Runnable)}). 49 * @throws TaskTimeoutException in case of the task being rejected because 50 * of the timeout (i.e. it cannot be started in time) 51 * @throws TaskRejectedException if the given task was not accepted 52 */ 53 void execute(Runnable task, long startTimeout); 54 55 } 56