int main(int argc, char* argv[]) { try { IThread* serverThread = new Thread; IThread* clientThread = new Thread; ServerData sdata; sdata.isServer = (argc >= 2); sdata.serverThread = serverThread; serverThread->run(serverCallback, &sdata); ClientData cdata; cdata.isServer = (argc >= 2); cdata.login = "******"; if (argc >= 2) cdata.login = argv[1]; cdata.clientThread = clientThread; if (sdata.isServer) sleep(2); clientThread->run(clientCallback, &cdata); clientThread->wait(); delete clientThread; delete serverThread; } catch (IThread::Exception& e) { std::cerr << "Babel error: " << e.what() << std::endl; } std::cout << "Bye" << std::endl; return 0; }
int main(int /*argc*/, char* /*argv*/ []) { IThread* mainThread = IThread::createThread(mainProc, (void*)"main"); mainThread->run(); mainThread->join(); printf("main end\n"); IThread::deleteThread(mainThread); return 0; }