public synchronized @ Nullable T next ( ) throws JiteratorLoadException { while ( nexting ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "[" + this + "] Waiting for another thread to pull item..." ) ; } try { wait ( 150L ) ; } catch ( InterruptedException e ) { /* ignore */ } } if ( loadException != null ) { throw new JiteratorLoadException ( loadException ) ; } nexting = true ; try { T t ; if ( waiting == null ) { throw new NoSuchElementException ( "Invalid attempt to get another element from empty iterator." ) ; } if ( ! waiting . isEmpty ( ) ) { t = waiting . get ( 0 ) ; waiting . remove ( 0 ) ; if ( waiting . isEmpty ( ) && loaded ) { waiting = null ; } return t ; } waitForPush ( ) ; if ( loadException != null ) { throw new JiteratorLoadException ( loadException ) ; } if ( waiting == null || waiting . isEmpty ( ) ) { throw new NoSuchElementException ( "Invalid attempt to get another element from empty iterator." ) ; } t = waiting . get ( 0 ) ; waiting . remove ( 0 ) ; if ( waiting . isEmpty ( ) && loaded ) { waiting = null ; } return t ; } finally { nexting = false ; notifyAll ( ) ; } }
Provides the next element in the jiterator . If this method is called prior to the jiterator being loaded with an item it will hang until either an item is added into the jiterator or the jiterator is marked as complete .