Hi everyone,
Well I am writing a program where there are two sets of threads. The first set has 4 threads and the second set has 6 threads. Now, in every round, I want the first set of threads to execute once in any order. Then the second set of threads to execute in any order. Only then should the program move on to the second round... E.g.
ROUND = 1;
First set of 4 threads run in any order.
Second set of 6 threads run in any order.
ROUND ++;
First set of 4 threads run in any order.
Second set of 6 threads run in any order.
ROUND ++;
First set of 4 threads run in any order.
Second set of 6 threads run in any order.
ROUND ++;
First set of 4 threads run in any order.
Second set of 6 threads run in any order.
.......and this continues...
I have tried to implement this, but I ended up using a monitor of my own and making a thread wait() until the monitor ID matches the thread ID. I have used while loops which makes the program inefficient and slow and it eliminates the whole purpose of using threads, i.e. to make the program efficient... Please help me out... How do I implement the process stated above? Thank you.