I have problems in mulithreads environment . I can create several threads that execute correctly, However the process never end. I can't wait for the finishing. I want to do some action when all my threads end but currently it is impossible. Here my code:
public static void main(String[] args){
public void run(){
ExecutorService exec = Executors.newFixedThreadPool(10);
try {
for(int i=0;i<100;i++){
final Integer a=i;
try {
exec.submit(new Runnable() {
@Override
public void run() {
System.out.println(a);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
Someone knows how to achieve my goal? Thanks!