Почему мой строковый поток не может работать с jthread?C++

Программы на C++. Форум разработчиков
Ответить
Гость
 Почему мой строковый поток не может работать с jthread?

Сообщение Гость »


I want to write an integer to a stringstream in another thread. I tried to do that in a jthread, but the stringstream seems not getting anything. If I turn to use thread, everything works well. Would you please help me about why this problem happens, and is there any way to analyze problems like this?

Here's an example piece of code, I tried to write integers to stringstream inside a jthread in the 2nd and 3rd blocks, but it didn't work. Writing integers to stringstream inside a thread instead, in the 4th and 5th blocks can work.

#include #include using namespace std; int main() { // write to stringstream stringstream sout1; sout1
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»