[ create a new paste ] login | about

Link: http://codepad.org/PSvVPVpV    [ raw code | fork ]

C++, pasted on Jul 31:
#include <thread>
#include <iostream>
#include <chrono>

class A
{
public:
	A(int a) : _a(a) {}

	void ThreadFun(int x)
	{
		std::cout << "class member : " << _a << std::endl;
		std::cout << "input param : " << x << std::endl;
		
		//std::this_thread::sleep_for(std::chrono::milliseconds(500));
	}
private:
	int _a;
};


int main()
{
	A a1(1);
	A a2(2);
	std::thread t1(std::bind(&A::ThreadFun, &a1, std::placeholders::_1), 100);
	t1.join();
	std::thread t2(std::bind(&A::ThreadFun, &a2, std::placeholders::_1), 999);
	t2.join();
	return 0;
}


Create a new paste based on this one


Comments: