#include <iostream>
#include <thread>
class Bar
{
public:
void operator()(int a)
{
std::cout << a << '\n';
}
};
int main()
{
Bar bar;
// Create and execute the thread
std::thread thread(bar, 10); // Pass 10 to functor object
// The functor object will be executed in a separate thread
// Wait for the thread to finish, this is a blocking operation
thread.join();
return 0;
}
ICAgICNpbmNsdWRlIDxpb3N0cmVhbT4KICAgICNpbmNsdWRlIDx0aHJlYWQ+CiAgICAgCiAgICBjbGFzcyBCYXIKICAgIHsKICAgIHB1YmxpYzoKICAgICAgICB2b2lkIG9wZXJhdG9yKCkoaW50IGEpCiAgICAgICAgewogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgYSA8PCAnXG4nOwogICAgICAgIH0KICAgIH07CiAgICAgCiAgICBpbnQgbWFpbigpCiAgICB7CiAgICAgICAgQmFyIGJhcjsKICAgICAgICAKICAgICAgICAvLyBDcmVhdGUgYW5kIGV4ZWN1dGUgdGhlIHRocmVhZAogICAgICAgIHN0ZDo6dGhyZWFkIHRocmVhZChiYXIsIDEwKTsgLy8gUGFzcyAxMCB0byBmdW5jdG9yIG9iamVjdAogICAgIAogICAgICAgIC8vIFRoZSBmdW5jdG9yIG9iamVjdCB3aWxsIGJlIGV4ZWN1dGVkIGluIGEgc2VwYXJhdGUgdGhyZWFkCiAgICAgCiAgICAgICAgLy8gV2FpdCBmb3IgdGhlIHRocmVhZCB0byBmaW5pc2gsIHRoaXMgaXMgYSBibG9ja2luZyBvcGVyYXRpb24KICAgICAgICB0aHJlYWQuam9pbigpOwogICAgIAogICAgICAgIHJldHVybiAwOwogICAgfQ==