I have an array list of Threads and I want to stop all threads in the list if the cancel button pressed from GUI. Is there any way to stop all these threads?
List<Thread> threads = new ArrayList<>();
EncryptThread encryptThread = null;
for(int j=0;j<fileEncrytionList.size();j++){
encryptThread = new EncryptThread();
encryptThread.setFilePath(fileEncrytionList.get(j));
encryptThread.setOutPutFile(fileName);
Thread t = new Thread(encryptThread);
t.start();
threads.add(t);
}
if(cancel button pressed) // stop all threads from arraylist