Create a List of Callable tasks
import java.util.concurrent.Callable;
public class Task implements Callable<String> {
@Override
public String call() throws Exception {
// implement code to run concurrently
return "";
}
}
List<Task> taskList = new ArrayList<Task>();
taskList.add(new Task());
taskList.add(new Task());
taskList.add(new Task());
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
threadPoolManager.setTaskList(taskList);
threadPoolManager.runManager();
ThreadPoolManager threadPoolManager = new ThreadPoolManager(20);
// OR
threadPoolManager.setPoolSize(20);
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
threadPoolManager.setCallback(new Callable<String>(){
@Override
public String call() throws Exception {
// implement code to be called when threads are done running
System.out.println("Thread done.");
return "";
}
});
Ameet Naik