Write a program (in C, or Java, or C++, or C#) that creates three new threads (besides the already existing main thread) and synchronizes them in such a way that each thread displays it's thread id in turn for 5 iterations. The output of the program should look like this: Thread 1 - iteration no. 1 Thread 2 - iteration no. 1 Thread 3 - iteration no. 1 Thread 1 - iteration no. 2 Thread 2 - iteration no. 2 Thread 3 - iteration no. 2 Thread 1 - iteration no. 3 Thread 2 - iteration no. 3 Thread 3 - iteration no. 3 Thread 1 - iteration no. 4 Thread 2 - iteration no. 4 Thread 3 - iteration no. 4 Thread 1 - iteration no. 5 Thread 2 - iteration no. 5 Thread 3 - iteration no. 5 Deliverables: the source code + a screenshot of the running program.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |