I am trying to write a simple code to print numbers in sequence. Scenario is like
Thread Number T1 1 T2 2 T3 3 T1 4 T2 5 T3
Well, the problem is that modulo 3 % 3 is 0. Change your threadIds to 0..2 instead of 1..3 and hopefully it should work.
3 % 3
0
threadId
0..2
1..3