How to run application fast using Executor in Java

class CallingClass{
public void method1(){
ExecutorService exService = Executors.newFixedThreadPool(2);
List<FutureTask> list=new ArrayList<FutureTask>();

FutureTask detailsTask= new FutureTask(new ProcessDetails (paginationDto));
exService.execute(detailsTask);
list.add(detailsTask);

FutureTask detailsTask1= new FutureTask(new ProcessDetails (paginationDto));
exService.execute(detailsTask1);
list.add(detailsTask1);
// Execute the call method
for(int i=0;i<count;i++){
list.get(i).get();
}

exService.shutdownNow();

}
}
class ProcessDetails implements Callable{

private PaginationDto pagination;

public ProcessDetails(PaginationDto pagination){
log.info(“Processing  Details”);
this.pagination = pagination;
}

@Override
public String call() throws Exception {
// do here your actual job
return “Task Finished”;
}

}

How to configure external folder for upload and download files in tomcat

Steps for configuration:
1)Create the folder in outside of the apache tomcats copy the path and paste in the below “context docbase” and “application.properties”

2)In the Apache tomcat Sever –> conf –>server .xml file add the below line and replace the docbase file path which we get in the above step

3)Need to configure the below new lines in the “application.properties” file
upload.filePath=
upload.urlPath=http:///output

How to Write large dataset into excel using Apache POI

By Using SXSSFWorkbook we can create excel files with large data.
While fetching dataset in for loop we have to flush the row data after some count like

// manually control how rows are flushed to disk
if(row % 100 == 0) {
((SXSSFSheet)dataSheet).flushRows(100); // retain 100 last rows and flush all others

// ((SXSSFSheet)sh).flushRows() is a shortcut for ((SXSSFSheet)sh).flushRows(0),
// this method flushes all rows
}