[Solved] How can I get my threaded program to print specific output


You could do this easily in two ways:

  1. Pass a ‘print token’ between the threads using two semaphores: thread 1 prints, signals semaphore A, waits on semaphore B then loops. Thread 2 waits on semaphore A, prints, signals semaphore B and loops.

  2. Write in-line, single-threaded code.

1

solved How can I get my threaded program to print specific output