wro4j-core/src/main/java/ro/isdc/wro/model/group/processor/PreProcessorExecutor.java
private String runInParallel(final List<Resource> resources, final ProcessingCriteria criteria)
      throws IOException {
    LOG.debug("Running preProcessing in Parallel");
    final StringBuffer result = new StringBuffer();
    final List<Callable<String>> callables = new ArrayList<Callable<String>>();
    for (final Resource resource : resources) {
      callables.add(new Callable<String>() {
        public String call()
            throws Exception {
          LOG.debug("Callable started for resource: {} ...", resource);
          return applyPreProcessors(resource, criteria);
        }
      });
    }
    final ExecutorService exec = getExecutorService();
    final List<Future<String>> futures = new ArrayList<Future<String>>();
    for (final Callable<String> callable : callables) {
      // decorate with ContextPropagatingCallable in order to allow spawn threads to access the Context
      final Callable<String> decoratedCallable = new ContextPropagatingCallable<String>(callable);
      futures.add(exec.submit(decoratedCallable));
    }

    for (final Future<String> future : futures) {
      try {
        result.append(future.get());
      } catch (final Exception e) {
        // propagate original cause
        final Throwable cause = e.getCause();
        if (cause instanceof WroRuntimeException) {
          throw (WroRuntimeException) cause;
        } else if (cause instanceof IOException) {
          throw (IOException) cause;
        } else {
          throw new WroRuntimeException("Problem during parallel pre processing", e);
        }
      }
    }
    return result.toString();
  }
private String runInParallel(final List<Resource> resources, final ProcessingCriteria criteria)
      throws IOException {
    LOG.debug("Running preProcessing in Parallel");
    final StringBuffer result = new StringBuffer();
    final List<Callable<String>> callables = new ArrayList<Callable<String>>();
    for (final Resource resource : resources) {
      callables.add(new Callable<String>() {
        public String call()
            throws Exception {
          LOG.debug("Callable started for resource: {} ...", resource);
          return applyPreProcessors(resource, criteria);
        }
      });
    }
    final ExecutorService exec = getExecutorService();
    final List<Future<String>> futures = new ArrayList<Future<String>>();
    for (final Callable<String> callable : callables) {
      // decorate with ContextPropagatingCallable in order to allow spawn threads to access the Context
      final Callable<String> decoratedCallable = new ContextPropagatingCallable<String>(callable);
      futures.add(exec.submit(decoratedCallable));
    }

    for (final Future<String> future : futures) {
      try {
        result.append(future.get());
      } catch (final Exception e) {
        // propagate original cause
        final Throwable cause = e.getCause();
        if (cause instanceof WroRuntimeException) {
          throw (WroRuntimeException) cause;
        } else if (cause instanceof IOException) {
          throw (IOException) cause;
        } else {
          throw new WroRuntimeException("Problem during parallel pre processing", e);
        }
      }
    }
    return result.toString();
  }
private String runInParallel ( final List < Resource > resources , final ProcessingCriteria criteria ) throws IOException { LOG . debug ( "Running preProcessing in Parallel" ) ; final StringBuffer result = new StringBuffer ( ) ; final List < Callable < String > > callables = new ArrayList < Callable < String > > ( ) ; for ( final Resource resource : resources ) { callables . add ( new Callable < String > ( ) { public String call ( ) throws Exception { LOG . debug ( "Callable started for resource: {} ..." , resource ) ; return applyPreProcessors ( resource , criteria ) ; } } ) ; } final ExecutorService exec = getExecutorService ( ) ; final List < Future < String > > futures = new ArrayList < Future < String > > ( ) ; for ( final Callable < String > callable : callables ) { // decorate with ContextPropagatingCallable in order to allow spawn threads to access the Context final Callable < String > decoratedCallable = new ContextPropagatingCallable < String > ( callable ) ; futures . add ( exec . submit ( decoratedCallable ) ) ; } for ( final Future < String > future : futures ) { try { result . append ( future . get ( ) ) ; } catch ( final Exception e ) { // propagate original cause final Throwable cause = e . getCause ( ) ; if ( cause instanceof WroRuntimeException ) { throw ( WroRuntimeException ) cause ; } else if ( cause instanceof IOException ) { throw ( IOException ) cause ; } else { throw new WroRuntimeException ( "Problem during parallel pre processing" , e ) ; } } } return result . toString ( ) ; }
runs the pre processors in parallel.

@return merged and pre processed content.
runs the pre processors in parallel .