#ifndef _NitX_h_ #define _NitX_h_ #include "Thread.h" #include "iostream.h" #include "Semaphore.h" #include "sleep.h" class NitX : public Thread { public: NitX(Semaphore* s1, Semaphore* s2, int *x, int *y, int *z) { this->s1 = s1; this->s2 = s2; this->x = x; this->y = y; this->z = z; } protected: virtual void run(){ for (int i = 1; i <= 10; ++i) { *x = i; *y = i*i; cout << "Producer produced: " << *x << " " << *y << endl; s1->signal(); s2->wait(); cout << "Sum counted: " << *x << " + " << *y << " = " << *z << endl; } cout << "NitX finnished" << endl; } int *x, *y, *z; Semaphore *s1, *s2; }; #endif // _NitX_h_