In ExecutorService, how can I group all the threads processing a specific course id and then upon one thread finish process that course id, close all the other threads which are in the process of that course id?
The number of threads which can process the course id untill one thread finish process, is not a fixed number.
Update:
So any threads enter to process this course, I am going to add them to a static collection.
Suppose for courseid1, thread1 is initially processing,
List l1 = new ArrayList();
l1.add(thread1);
Map t = new Hashmap();
t.add("courseid1":l1)
So while thread1 is in process another thread comes to process courseid1,
l1.add(thread2);
Then once thread1 see the course status is complete, I will send success to all the threads in list l1.