Skip to content

Instantly share code, notes, and snippets.

@kasramp
Created August 4, 2020 22:06
Show Gist options
  • Save kasramp/8e9f4399e032e77d1b0209042c63b4fa to your computer and use it in GitHub Desktop.
Save kasramp/8e9f4399e032e77d1b0209042c63b4fa to your computer and use it in GitHub Desktop.
public class Mail {
public void doSendMails() {
//Creating ArrayList of the ThreadClass to hold reference of the threads
ArrayList<ThreadClass> mailManThreads = new ArrayList();
for (int cnt = 0; cnt < mailManThreads.size(); cnt++) {
Vector oneMailQueue = new Vector();
oneMailQueue = allMails.get(cnt);
ThreadClass oneMailManThread = new ThreadClass();
oneMailManThread.start(oneMailQueue);
mailManThreads.add(oneDealerThread);
}
// Joins all threads to main thread to avoid main thread to continue without finishing the rest of threads
for (int cnt = 0; cnt < mailManThreads.size(); cnt++) {
mailManThreads.get(cnt).join();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment