public final Task < T , TError > start ( ) { if ( this instanceof Done ) return this ; if ( cancelling != null ) result . cancelled ( cancelling ) ; synchronized ( this ) { if ( result . isCancelled ( ) ) return this ; if ( status != Task . STATUS_NOT_STARTED ) { if ( status >= Task . STATUS_DONE ) throw new RuntimeException ( "Task already done: " + description + " with " + ( result . getError ( ) != null ? "error " + result . getError ( ) . getMessage ( ) : "success" ) ) ; throw new RuntimeException ( "Task already started (" + status + "): " + description ) ; } // check if waiting for time if ( nextExecution > 0 ) { long now = System . currentTimeMillis ( ) ; if ( nextExecution > now ) { TaskScheduler . schedule ( this ) ; return this ; } } // ready to be executed sendToTaskManager ( ) ; return this ; } }
Ask to start the task . This does not start it immediately but adds it to the queue of tasks to execute .