I have a service today that I need to calculate its execution time with multiple accesses, for this I am trying to execute concurrent threads and that loguem this time, the problem is that for the run method of the Thread class I can not pass parameters and in case I I need these parameters to execute the service. How can I do this? I'm in the right way? Here is the code:
for(int x = 0; x<50 ; x++){
new Thread() {
long tempInicial = System.currentTimeMillis();
@Override
public void run(HttpServletRequest request,
HttpServletResponse response, String sequence,
CommandMapping commMapping, CommandForm form) throws FactoryException { //ERRO -> Não posso ter esses parâmetros
Command command = CommandFactory.getInstance().getCommand(
commMapping.getCommandPath());
CommandResponse commResponse = null;
try {
commResponse = command.executeCommand(form, request, response, commMapping.isValidateForm());
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long tempFinal = System.currentTimeMillis();
long dif = (tempFinal - tempInicial);
log.info("Requisição " + ": " + String.format("%02d segundos e %02d milisegundos", dif/60, dif%60));
}
}.start();
}