multithreading - C++ write to stdin (in Windows) -


i have multi-threaded windows console app control thread runs user input loop this:

char c; {     cin >> c;     // alter activity based on c } while(c != 'q') // tell other threads close, .join(), , cleanup 

however @ time want program able gracefully quit. obvious way put "q\n" onto stdin stream. there reasonable way that?

or alternative callback force exit main control loop (on primary thread) program falls through subsequent cleanup methods?

(the closest have found far this requires spawning child process , seems kludgy overkill @ best.)

you can use flag loop break condition of threads. problem interthread-communication can solved synchronization objects came c++11 atomics or mutex.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -