Can I Get a definite approach for achieving this. I have used join and wait for the alternative producer and consumer execution. This question was asked in an interview. He did not like my solution. I have also suggested a loop inside a synchronized block for consuming / producing resources.
below is the expected output:
p1 c1 p3 c1 p2 c1 p2 c1 . . .