Answer the question
In order to leave comments, you need to log in
How to start and stop a parallel thread?
We need to make such a program. The console program waits in an infinite loop for input of text commands. When entering a command, you need to start calculations in a parallel thread (or process) and switch to the waiting mode for the next command. In the process of calculation, the result is gradually refined depending on the depth of research achieved. When a certain time elapses or when a stop command is entered, the calculation must be stopped immediately and the result returned.
How can this be implemented? Suggest something to read. Only the most simple, understandable, for dummies. I don't understand how to create a thread, how to stop it, how to return results, how to share access to shared variables.
I came across this example
#include <thread>
void threadFunction()
{
// do smth
}
int main()
{
std::thread thr(threadFunction);
thr.join();
return 0;
}
Answer the question
In order to leave comments, you need to log in
shatalov.ghost17.ru/winapi/threads.html
From a C++ point of view, a thread is a regular function that has a specific prototype. The CreateThread function is used to create a thread.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question