- 4

Why thread.detach not continuing when using thread::sleep_for in main thread but it continues if i loop print " "

https://code.sololearn.com/chnWmjf3UN01/?ref=app and works when looping printing: https://code.sololearn.com/cH3b1qlP3i81/?ref=app

7th Mar 2021, 9:24 AM
return 0;
return 0; - avatar
18 ответов
+ 1
Im waiting at the end so detach can continue
7th Mar 2021, 12:15 PM
return 0;
return 0; - avatar
+ 1
Have you tried your code outside of code playground?
7th Mar 2021, 12:20 PM
Sonic
Sonic - avatar
+ 1
Is sololearn compiler broken
7th Mar 2021, 12:26 PM
return 0;
return 0; - avatar
+ 1
I tried both
7th Mar 2021, 12:27 PM
return 0;
return 0; - avatar
+ 1
It's not broken but it does not support all features of an offline system.
7th Mar 2021, 12:27 PM
Sonic
Sonic - avatar
+ 1
Only the one with loop is working
7th Mar 2021, 12:27 PM
return 0;
return 0; - avatar
+ 1
The other is Saying no output
7th Mar 2021, 12:27 PM
return 0;
return 0; - avatar
+ 1
E.g. delays/sleep will not work on code playground.
7th Mar 2021, 12:27 PM
Sonic
Sonic - avatar
+ 1
I tried on dev c++
7th Mar 2021, 12:28 PM
return 0;
return 0; - avatar
+ 1
It works there
7th Mar 2021, 12:28 PM
return 0;
return 0; - avatar
+ 1
I use it to pause the program
7th Mar 2021, 12:28 PM
return 0;
return 0; - avatar
+ 1
Detach will continue
7th Mar 2021, 12:28 PM
return 0;
return 0; - avatar
+ 1
Is sololearn compiler broken
7th Mar 2021, 12:29 PM
return 0;
return 0; - avatar
+ 1
return 0; it's not broken but codes with multithreading, sleep/delay will not work on code playground.
7th Mar 2021, 12:47 PM
Sonic
Sonic - avatar
+ 1
I tried using different compilers
8th Mar 2021, 4:29 PM
return 0;
return 0; - avatar
+ 1
It worked there
8th Mar 2021, 4:30 PM
return 0;
return 0; - avatar
+ 1
Sololearn c++compiler isnt good
8th Mar 2021, 4:30 PM
return 0;
return 0; - avatar
+ 1
Hello return 0; I want to inform you, that I have "fixed" your question. Your question is now in the title and your codes in the description. That helps the user to see which problem you have. And I fixed the tags so that your question is searchable. Btw: You can also edit your own questions to change title/description/tags. For the next time you can read here how to ask clear questions in q&a: https://www.sololearn.com/blog/38/8-simple-rules-to-get-help-from-the-community Happy coding :)
11th Mar 2021, 4:45 PM
Denise Roßberg
Denise Roßberg - avatar