test_5542_3.cpp 817 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2010 Vicente Botet
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #define BOOST_THREAD_VERSION 2
  6. #include <iostream>
  7. #include <boost/thread/thread_only.hpp>
  8. #include <boost/date_time.hpp>
  9. void workerFunc()
  10. {
  11. boost::posix_time::seconds workTime(3);
  12. std::cout << "Worker: running" << std::endl;
  13. // Pretend to do something useful...
  14. boost::this_thread::sleep(workTime);
  15. std::cout << "Worker: finished" << std::endl;
  16. }
  17. int main()
  18. {
  19. std::cout << "main: startup" << std::endl;
  20. boost::thread workerThread(workerFunc);
  21. std::cout << "main: waiting for thread" << std::endl;
  22. workerThread.join();
  23. std::cout << "main: done" << std::endl;
  24. return 0;
  25. }