The only problem with your code is the max val of i in the loop.
Increase it to a high value, you'll see the results. Hope the issue
is self-explanatory. You first thread completes much before the
second thread could start even. Thatz why you see them printed
sequentially.