Question about threads | Sololearn: Learn to code for FREE!

+2

Question about threads

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

12/6/2019 9:48:12 AM

Rustam Aliev

5 Answers

New Answer

+3

It print....

+2

it looks like you some some infinite loops setup.

+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!

+2

Welcome! 🙃 May be in the end was "Time exceeded"...

+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.