C++11多线程学习3 : join和detach

在上一篇文章C++11多线程学习1中的代码,我们使用了join。但是其实使用detach也是一样的结果。 int _tmain(int argc, _TCHAR* argv[]) { std::thread t1(test, "t1", 1000); std::thread t2(test, "t2", 1500); t1.join(); // detach() t2.join();

C++11多线程学习2 : 类

C++11多线程学习1中,使用的函数是全局函数。 如果换成类函数又怎么样呢? 看下面的例子: #include <iostream> #include <windows.h> #include <thread> class test { public: test() {} ~test() {} public: void testcout(const std::string& str, int time) { for (int i =

C++11多线程学习1 : 初识

最近开始学习新的知识啦,哈哈。 C++11开始支持多线程编程,之前多线程编程都需要系统的支持,在不同的系统下创建线程需要不同的API。 如今就可