public List < Future < T > > execute ( @ SuppressWarnings ( "unchecked" ) Task < T > ... tasks ) { List < Future < T >> futures = new ArrayList < Future < T > > ( ) ; if ( tasks != null ) { synchronized ( queue ) { int i = 0 ; for ( Task < T > task : tasks ) { if ( task != null ) { this . tasks . add ( task ) ; TaskCallable < T > callable = new TaskCallable < T > ( i ++ , queue , task ) ; for ( TaskObserver < T > observer : observers ) { observer . onTaskStarting ( task ) ; } futures . add ( executor . submit ( callable ) ) ; for ( TaskObserver < T > observer : observers ) { observer . onTaskStarted ( task ) ; } } } } } return futures ; }
Starts the given set of tasks asynchronously returning their futures .