title: process multiple object read through ItemReader at same time(concurrently) with Spring batch
body: <p>I am trying to read data from the database, and run process on each object concurrently.</p>
  
  <blockquote>
    <p>My config as below,</p>
  </blockquote>
  
  <pre><code>@Bean
  public Job job() {
      return jobBuilderFactory.get("job").incrementer(new RunIdIncrementer()).listener(new Listener(videoDao))
              .flow(step1()).end().build();
  }
  
  @Bean
  public Step step1() {
      return stepBuilderFactory.get("step1")
              .&lt;VideosDTO, VideosDTO&gt;chunk(3)
              .reader(databaseVideoItemReader(null))
              .processor(new Processor())
              .writer(new Writer(videoDao))
              .build();
  }
  
  
  
   @Bean
   @StepScope
  ItemReader&lt;VideosDTO&gt; databaseVideoItemReader(@Value("#{jobParameters[userId]}") String userId) {
      logger.info("Fetching videos for userId:"+userId);
      JdbcCursorItemReader&lt;VideosDTO&gt; databaseReader = new JdbcCursorItemReader&lt;&gt;();
      databaseReader.setDataSource(dataSource);
      databaseReader.setSql("SELECT * FROM voc.t_videos where user_id="+userId+"AND job_success_ind='N'");
      databaseReader.setRowMapper(new BeanPropertyRowMapper&lt;&gt;(VideosDTO.class));
     // databaseReader.open(new ExecutionContext());
     ExecutionContext executionContext= new ExecutionContext();
     executionContext.size();
     databaseReader.open(executionContext);
  
      return databaseReader;
  }
  </code></pre>
  
  <blockquote>
    <p>My item process is as below,</p>
  </blockquote>
  
  <pre><code>@Override
  public VideosDTO process(VideosDTO videosDTO) throws Exception {
      log.info("processing........" + videosDTO.getVideoUrl());
  
      try {
          Process p = Runtime.getRuntime()
                  .exec("C:\\Program Files\\Git\\bin\\bash.exe " + "D:\\DRM\\script.sh " + videosDTO.getVideoUrl());
          // .exec("D:\\PortableGit\\bin\\bash.exe
          // D:\\Vocabimate_Files\\script.sh "+videosDTO.getVideoUrl());
          // Thread.sleep(1000);
          Thread.sleep(1000);
          p.destroy();
          try {
              p.waitFor();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          try (InputStream is = p.getErrorStream()) {
              int in = -1;
              while ((in = is.read()) != -1) {
                  System.out.print((char) in);
              }
          }
          try (InputStream is = p.getInputStream()) {
              int in = -1;
              while ((in = is.read()) != -1) {
                  System.out.print((char) in);
              }
          }
      } catch (IOException e2) {
          // TODO Auto-generated catch block
          e2.printStackTrace();
      }
  
      return videosDTO;
  }
  </code></pre>
  
  <blockquote>
    <p>writer is as below:</p>
  </blockquote>
  
  <pre><code>    @Override
  public void write(List&lt;? extends VideosDTO&gt;videosList) throws Exception {
  
      for(VideosDTO vid:videosList){
          log.info("writting...."+vid.getVideoUrl());
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>Suppose if there are 3 Objects fetched from DB this code first
    complete process on first object,than second and than third than
    starts writing.I want to Run process on the three object concurrently
    at same time,than perform writing operation.</p>
  </blockquote>
  
  <p>Is there any way to do this?</p>