c++ inter thread communication : here is my simple code, i want to get in the console_task, the value of the variable i in the dialer_task... without using global variable

Thanks for help

    #include <stdio.h>
    #include <sys/types.h>
    
    
    
    #include <signal.h>
    #include <strings.h>
    #include <string.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <thread>
    #include "console.hpp"
    
    using namespace std;
    
    void console_task(){
        console();
    }
    
    void dialer_task(){
        int i=0;
        while (1) {
            printf("LOOP %d\n",i);
            i++;
            sleep(5);
        }
    }
    
    int main()
    {
        thread t1(console_task);
        thread t2(dialer_task);
        
        t1.join();
        t2.join();
        return 0;
    }

