class ResourceMgr{ private: Lock lock; CV cv; int r; // Number of resources int t; // Number of threads int avail[]; // avail[i]: instances of resource i available int max[][]; // max[i][j]: max of resource i needed by thread j int alloc[][]; // alloc[i][j]: current allocation of resource i to thread j ... }