Interface for deferred tasks. Classes implementing this interface may use TaskOptions#payload(DeferredTask) to serialize the DeferredTask into the payload of the
task definition. The DeferredTask#run() method will be called when the task is received
by the built in DeferredTask servlet.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eDeferredTask\u003c/code\u003e is an interface for tasks that can be serialized into a task definition's payload using \u003ccode\u003eTaskOptions#payload(DeferredTask)\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDeferredTask#run()\u003c/code\u003e method is invoked when the task is handled by the built-in \u003ccode\u003eDeferredTask\u003c/code\u003e servlet.\u003c/p\u003e\n"],["\u003cp\u003eA successful execution of the \u003ccode\u003eDeferredTask#run()\u003c/code\u003e method is considered to have been successful unless \u003ccode\u003eDeferredTaskContext#markForRetry\u003c/code\u003e is specifically called.\u003c/p\u003e\n"],["\u003cp\u003eExceptions thrown by \u003ccode\u003eDeferredTask#run()\u003c/code\u003e are treated as a failure, initiating a retry unless \u003ccode\u003eDeferredTaskContext#setDoNotRetry(boolean)\u003c/code\u003e is true.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDeferredTask\u003c/code\u003e interface implements both \u003ccode\u003eRunnable\u003c/code\u003e and \u003ccode\u003eSerializable\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Interface DeferredTask (2.0.0)\n\n public interface DeferredTask extends Runnable, Serializable\n\nInterface for deferred tasks. Classes implementing this interface may use [TaskOptions#payload(DeferredTask)](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.TaskOptions#com_google_appengine_api_taskqueue_TaskOptions_payload_com_google_appengine_api_taskqueue_DeferredTask_) to serialize the [DeferredTask](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.DeferredTask) into the payload of the\ntask definition. The DeferredTask#run() method will be called when the task is received\nby the built in DeferredTask servlet.\n\nNormal return from this method is considered success and will not retry unless [DeferredTaskContext#markForRetry](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.DeferredTaskContext#com_google_appengine_api_taskqueue_DeferredTaskContext_markForRetry_) is called. Exceptions thrown from this method will indicate a\nfailure and will be processed as a retry attempt unless [DeferredTaskContext#setDoNotRetry(boolean)](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.DeferredTaskContext#com_google_appengine_api_taskqueue_DeferredTaskContext_setDoNotRetry_boolean_) was set to `true`. \n\nImplements\n----------\n\n[Runnable](https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html), [Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)"]]