C++ (Qt)QBuffer buf;
QMutex m;
C++ (Qt)class Th1: public QThread{public: void run();}void Th1::run(){ m.lock(); buf.append("Th1"); m.unlock(); exec();} class Th2: public QThread{public: void run();}void Th2::run(){ m.lock(); buf.append("Th2"); m.unlock(); exec();} Th1 th1;Th2 th2;th1.start();th2.start();
C++ (Qt)QMutex m1;QMutex m2;class Th1: public QThread{public: void run();}void Th1::run(){ m1.lock(); buf.append("Th1"); m1.unlock(); exec();} class Th2: public QThread{public: void run();}void Th2::run(){ m2.lock(); buf.append("Th2"); m2.unlock(); exec();} Th1 th1;Th2 th2;th1.start();th2.start();