use of com.safframework.study.task.core.common.ITask in project RxJavaInAction by fengzhizi715.
the class TasksController method concurrent.
@GetMapping("/concurrent")
public ApiResponseDTO concurrent(@RequestParam("task") int[] taskDelaysInSeconds, @RequestParam("threads") int numberOfConcurrentThreads) {
StopWatch watch = new StopWatch();
watch.start();
List<ITask> delayedTasks = IntStream.of(taskDelaysInSeconds).mapToObj(MockTask::new).collect(Collectors.toList());
new ConcurrentTasksExecutor(numberOfConcurrentThreads, delayedTasks).execute();
watch.stop();
return new ApiResponseDTO(watch.getTotalTimeSeconds());
}
Aggregations