主线程需要阻塞一下,您的情况是线程创建后又立刻结束、线程崩溃了。
可以加thread->join()让程序一直运行不要退出
ThreadedClient threadedClient(listenport); auto thread = threadedClient.subscribe(hostName, port, onehandler, "replayStreamTB", "printStreamTB", -1, true, nullptr, false, false, sdsp); cout<<"Successed to connect to subscribe replayStreamTB"<<endl; thread->join();