#include <thread>
#include <iostream>
struct Yoba {
Yoba() { j = ++i; }
void run(const char* desk) { std::cout << desk << ": " << j << std::endl; }
static int i;
int j;
};
int Yoba::i{ 0 };
int
main()
{
Yoba y1{}; Yoba y2{}; Yoba y3{};
auto th1 = std::thread(&Yoba::run, &y1, "alo");
auto th2 = std::thread(&Yoba::run, &y3, "yoba");
auto th3 = std::thread(&Yoba::run, &y2, "eto ti?");
th1.join();
th2.join();
th3.join();
}
I2luY2x1ZGUgPHRocmVhZD4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IFlvYmEgewoJWW9iYSgpIHsgaiA9ICsraTsgfQoJdm9pZCBydW4oY29uc3QgY2hhciogZGVzaykgeyBzdGQ6OmNvdXQgPDwgZGVzayA8PCAiOiAiIDw8IGogPDwgc3RkOjplbmRsOyB9CglzdGF0aWMgaW50IGk7CglpbnQgajsKfTsKCmludCBZb2JhOjppeyAwIH07CgppbnQKbWFpbigpCnsKCVlvYmEgeTF7fTsgWW9iYSB5Mnt9OyBZb2JhIHkze307CglhdXRvIHRoMSA9IHN0ZDo6dGhyZWFkKCZZb2JhOjpydW4sICZ5MSwgImFsbyIpOwoJYXV0byB0aDIgPSBzdGQ6OnRocmVhZCgmWW9iYTo6cnVuLCAmeTMsICJ5b2JhIik7CglhdXRvIHRoMyA9IHN0ZDo6dGhyZWFkKCZZb2JhOjpydW4sICZ5MiwgImV0byB0aT8iKTsKCXRoMS5qb2luKCk7Cgl0aDIuam9pbigpOwoJdGgzLmpvaW4oKTsKfQ==