
Hi Is there anyway to reduce overhead of threadFoo() call in this simple program ? class baseClass { public: void foo(){ boost::posix_time::milliseconds delay(143); boost::this_thread::sleep(delay); } void threadFoo(){ threadObjOne = boost::thread(&baseClass::foo, this); threadObjTwo = boost::thread(&baseClass::foo, this); threadObjOne.join(); threadObjTwo.join(); } private: boost::thread threadObjOne; boost::thread threadObjTwo; }; int main(){ std::cout<< "main startup"<<std::endl; baseClass baseObj; tick_t startTime,endTime; rdtscll(startTime); baseObj.foo(); rdtscll(endTime); std::cout<<"native foo() call takes "<< endTime-startTime <<" clock cycles"<<std::endl; rdtscll(startTime); baseObj.threadFoo(); rdtscll(endTime); std::cout<<"Thread foo() call takes "<< endTime-startTime <<" clock cycles"<<std::endl; } The output is : main startup native foo() call takes 368222398 clock cycles Thread foo() call takes 372600905 clock cycles