private void doBatchWork ( BatchBackend backend ) throws InterruptedException { ExecutorService executor = Executors . newFixedThreadPool ( typesToIndexInParallel , "BatchIndexingWorkspace" ) ; for ( IndexedTypeIdentifier indexedTypeIdentifier : rootIndexedTypes ) { executor . execute ( new BatchIndexingWorkspace ( gridDialect , searchFactoryImplementor , sessionFactory , indexedTypeIdentifier , cacheMode , endAllSignal , monitor , backend , tenantId ) ) ; } executor . shutdown ( ) ; endAllSignal . await ( ) ; // waits for the executor to finish }
Will spawn a thread for each type in rootEntities they will all re - join on endAllSignal when finished .