/** Some Future task which needs to complete before this task completes */ synchronized public Futures add( Future f ) { if( f == null ) return this; if( f.isDone() ) return this; // NPE here if this Futures has already been added to some other Futures // list, and should be added to again. if( _pending_cnt == _pending.length ) { cleanCompleted(); if( _pending_cnt == _pending.length ) _pending = Arrays.copyOf(_pending,_pending_cnt<<1); } _pending[_pending_cnt++] = f; return this; }