#include <iostream> #include <thread> void initializeMembersOnlyResources() { // Assume this process takes 2-3 min to setup the resources std::cout << "Initializing ....\n"; } bool authorize(char* username, char* password) { bool isMember = false; // calling dummy function // isMember = checkDb(username, password); return isMember; } int main(int argc, char** argv) { if (argc == 3) // argv[1] is username. argv[2] is password { std::thread t(initializeMembersOnlyResources); bool isMember = authorize(argv[1], argv[2]); if (isMember) { t.join(); // wait till our members only resource initialization is done } else { std::cout << "You are not a member. But you can still use some non members funcionality of the program\n"; } } // some more functionality which is free for non members // assume some functionality here. std::cout << "Non member facilities available here\n"; }