Callable's call method is not returning list. Also when a debugger point kept at line 'return strList;' in call(), its not coming there at any point of time.
Could someone help, where its getting wrong.
Thanks in advance !
private static void getThreadNameList() {
List<String> strList=null;
ExecutorService executorService = Executors.newFixedThreadPool(3);
Future<List<String>> future = executorService.submit(new MyCallables());
try {
strList = future.get();
} catch (InterruptedException | ExecutionException e) { }
for(String s:strList) {
System.out.println(s);
}
}
class MyCallables implements Callable<List<String>>{
List<String> strList=null;
@Override
public List<String> call() throws Exception {
for(int i=0;i<=10;i++) {
strList.add(Thread.currentThread().getName());
}
return strList;
}
}