001/* 002 * Copyright 2002-2012 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.scheduling; 018 019/** 020 * Extension of the Runnable interface, adding special callbacks 021 * for long-running operations. 022 * 023 * <p>This interface closely corresponds to the CommonJ Work interface, 024 * but is kept separate to avoid a required CommonJ dependency. 025 * 026 * <p>Scheduling-capable TaskExecutors are encouraged to check a submitted 027 * Runnable, detecting whether this interface is implemented and reacting 028 * as appropriately as they are able to. 029 * 030 * @author Juergen Hoeller 031 * @since 2.0 032 * @see commonj.work.Work 033 * @see org.springframework.core.task.TaskExecutor 034 * @see SchedulingTaskExecutor 035 * @see org.springframework.scheduling.commonj.WorkManagerTaskExecutor 036 */ 037public interface SchedulingAwareRunnable extends Runnable { 038 039 /** 040 * Return whether the Runnable's operation is long-lived 041 * ({@code true}) versus short-lived ({@code false}). 042 * <p>In the former case, the task will not allocate a thread from the thread 043 * pool (if any) but rather be considered as long-running background thread. 044 * <p>This should be considered a hint. Of course TaskExecutor implementations 045 * are free to ignore this flag and the SchedulingAwareRunnable interface overall. 046 */ 047 boolean isLongLived(); 048 049}