jeudi 4 mai 2017

Changing a variable in an already running function. C++

i am creating my first nacl app and encountered with this issue : i need to stop a running while loop by changing the condition.

My Code: (kind of looks likes this)

var flag = 1;     
static void Test1() {
        while (flag) {
          sleep(2); 
      }    
    }

i want to change flag ( flag =0) in a safe way by calling another function to stop the infinite loop. How can i do it ic C++? any references will help as well!.

Aucun commentaire:

Enregistrer un commentaire