you are running a loop 10 times and creating a thread object each time --> so 10 different object
Inside run method, you are trying to lock thread object and in count method as well.
Main thread will shoot 10 objects --> 10 threads.
Each thread will locks its own object and print a incremental static number.
10 different threads can run in any manner and they can change the number value in any manner.
This is what happening.
solution -
If you want to print a sequential 1-10. Make sure all your 10 threads lock same object Or create one thread object and run it 10 times.
Post by:autobot
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, the permaculture playing cards