Here is the initial state of the buffers. buffers[0] buffers[1] buffers[2] 000000000000 ^ | 000000000000 ^ | 000000000000 ^ | Starting producer and consumer threads 100000000000 ^ | 120000000000 ^ | 300000000000 ^ | 000000000000 |^ 300000000000 ^ | 330000000000 ^ | 020000000000 | ^ 000000000000 |^ 333000000000 ^ | 333100000000 ^ | 121000000000 ^ | 333120000000 ^ | 121300000000 ^ | 002000000000 | ^ 000000000000 |^ 000300000000 | ^ 000000000000 |^ 000010000000 | ^ 000000000000 |^ 121320000000 ^ | 121321000000 ^ | 333122000000 ^ | 033122000000 | ^ 003122000000 | ^ 121321200000 ^ | 121321230000 ^ | 000122000000 | ^ 000022000000 | ^ 121321233000 ^ | 121321233100 ^| 000002000000 | ^ 000000000000 |^ 000000300000 | ^ 000000000000 |^ 000002000000 | ^ 000000000000 |^ 000000010000 | ^ 000000000000 |^ 000000200000 | ^ 021321233100 | ^ 000000220000 | ^ 001321233100 | ^ 000000020000 | ^ 000000023000 | ^ 000000002000 | ^ 000000000000 |^ 000000023300 | ^ 000000003300 | ^ 000000003310 | ^ 000000000310 | ^ 000321233100 | ^ 000000000200 | ^ 000000000010 | ^ 000000000000 |^ 000000000230 | ^ 000321233110 | ^ 000000000003 ^ | 000000000000 ^ | 200000000000 ^ | 000000000000 |^ 030000000000 | ^ 000000000000 |^ 000321233113 ^ | 003000000000 | ^ 000000000231 ^ | 200000000231 ^ | 200000000031 ^ | 200000000001 ^ | 000000000000 |^ 200321233113 ^| 000300000000 | ^ 230000000001 ^ | 210321233113 * 000000000000 |^ 232000000001 ^ | 232000000000 ^ | 232100000000 ^ | 232130000000 ^ | 000030000000 | ^ 000000000000 |^ 232133000000 ^ | Threads stopped.