#include <thread>
#include <mutex>
#include <iostream>
using namespace std;

class Point {
public:
    Point(): x(0), y(0) {
    }
    void stepNorthEast() {
        lock_guard<mutex> lock(m);
        x++;
        y++;
    }
    bool isNorthEast() const {
        lock_guard<mutex> lock(m);
        return x == y;
    }
private:
    mutable mutex m;
    int x, y;
};

class TestPoint {
private:
    Point p;
    void thread1() {
        for (int i = 0; i < 20000000; i++)
            p.stepNorthEast();
    }
    void thread2() {
        for (int i = 0; i < 20000000; i++)
            if (!p.isNorthEast())
                cout << "Probleem!" << endl;
    }
public:
    void test() {
        thread t1(&TestPoint::thread1, this); 
        thread t2(&TestPoint::thread2, this); 
        t1.join();
        t2.join();
        cout << "Einde." << endl;
    }
};

int main() { 
    TestPoint tp;
    tp.test();
    cin.get();
    return 0; 
}