Difference between revisions of "CPP/Boost/Threads"
From ProgrammingExamples
< CPP
(→Threads.cpp) |
(→Threads.cpp) |
||
Line 32: | Line 32: | ||
{ | { | ||
temp = sin(i) / i; | temp = sin(i) / i; | ||
− | cout << "\r" << setw(10) << i << setw(10) << temp; | + | std::cout << "\r" << std::setw(10) << i << setw(10) << temp; |
− | cout.flush(); | + | std::cout.flush(); |
} | } | ||
std::cout << "End LongFunction" << std::endl; | std::cout << "End LongFunction" << std::endl; |
Revision as of 21:55, 23 November 2010
Threads.cpp
#include <iostream> #include <vector> #include <cstdlib> #include <cmath> #include <boost/thread.hpp> void LongFunction(); int main(int argc, char* argv[]) { std::cout << "Main: Before thread call" << std::endl; boost::thread MyThread(&LongFunction); std::cout << "Main: After thread call" << std::endl; MyThread.join(); return 0; } void LongFunction() { std::cout << "Start LongFunction" << std::endl; unsigned int BigNum = 1e7; double temp; for(unsigned int i = 1; i < BigNum; i++) { temp = sin(i) / i; std::cout << "\r" << std::setw(10) << i << setw(10) << temp; std::cout.flush(); } std::cout << "End LongFunction" << std::endl; }