+ 2

Question about threads

Why this code do not print in console string "Second thread stopped"? https://code.sololearn.com/crLaPIbBjL3R/?ref=app

6th Dec 2019, 9:48 AM
Rustam Aliev
Rustam Aliev - avatar
5 Respostas
+ 3
It print....
6th Dec 2019, 10:10 AM
id001x
id001x - avatar
+ 2
it looks like you some some infinite loops setup.
6th Dec 2019, 10:30 AM
laura
+ 2
laura , loop in main() just for testing thread - not infinite loop ;-) id001x , i don't understand whats happened, but it print only after publishing. When script is beeing private, console does not printing last string from second thread. 2All: thanks a lot!
6th Dec 2019, 10:36 AM
Rustam Aliev
Rustam Aliev - avatar
+ 2
Welcome! 🙃 May be in the end was "Time exceeded"...
6th Dec 2019, 10:41 AM
id001x
id001x - avatar
+ 2
@Rustam Allev When I ran the code as is... it never completed and nothing was displayed. when I changed to (a == b). It ran and statements were printed out. The 2nd statement did not print. I changed the while (!threadstops) to While(threadstops). the 2nd statement did print and it did not run continuously. I haven't messed with threading hardly at all.. ... it's just what I observed..and I don't know if this helps. 😃 I'm sure someone else may come along and give a better answer.
6th Dec 2019, 10:43 AM
laura