+ 3

why the loop in threads runs 1 execution?

Help! Look my code "MultiThreading". Why instead 3 executions the loop of Thread1 and Thread2 going 1 execution in the sandbox?

29th Nov 2019, 1:50 PM
В. Чумаков
В. Чумаков - avatar
3 Antworten
+ 5
I am not exactly sure After experimenting a little bit with your code I figured out problem When you do Thread.sleep(1000) in a loop, that means that thread will go in waiting stage for 1 second, but in this time the loop completes it's running so you get to see it running only one time. What experiment I did was changing sleep value to low, I changed it to 100 and it executed 2 times. Hope this helps. 🤓
29th Nov 2019, 2:15 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
Thanks for answer)
29th Nov 2019, 6:04 PM
В. Чумаков
В. Чумаков - avatar
- 2
Hi
30th Nov 2019, 12:16 PM
arjun arjun