I have checked several questions and answers here and there (example), and I can't seem to find a solution or approach to what I am looking for.
I have a program that as soon as it begins, it will never stop unless the user inputs whatever.
So threads are going and doing some calculus, and it never stops (I want it to be that way).
But I want to be able to make it stop as soon as the user inputs something, and then, show the final results (this is not difficult).
So my main question is: is there a way to be listening to an input at the same time as the program is running and showing the process? (Imagine, showing numbers going 1 by 1 (1,2,3,4,5), printing them, and at the same time, be able to input whatever value.)
(What I thought it is making in the #pragma omp parallel for
, is use a shared variable (a flag), and an if
inside the loop, so as soon as the flag is true
or false
, break;
.)