test_7665.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #define BOOST_THREAD_USES_LOG
  7. #include <iostream>
  8. #include <boost/thread/thread_only.hpp>
  9. #include <boost/thread/detail/log.hpp>
  10. void thread()
  11. {
  12. BOOST_THREAD_LOG << "<thrd" << BOOST_THREAD_END_LOG;
  13. try {
  14. boost::this_thread::sleep_for(boost::chrono::seconds(30));
  15. } catch (...)
  16. {
  17. BOOST_THREAD_LOG << "thrd exception" << BOOST_THREAD_END_LOG;
  18. throw;
  19. }
  20. //while (1) ; // Never quit
  21. BOOST_THREAD_LOG << "thrd>" << BOOST_THREAD_END_LOG;
  22. }
  23. boost::thread example(thread);
  24. int main()
  25. {
  26. BOOST_THREAD_LOG << "<main" << BOOST_THREAD_END_LOG;
  27. boost::this_thread::sleep_for(boost::chrono::seconds(30));
  28. BOOST_THREAD_LOG << "main" << BOOST_THREAD_END_LOG;
  29. //while (1) ; // Never quit
  30. example.join();
  31. BOOST_THREAD_LOG << "main>" << BOOST_THREAD_END_LOG;
  32. return 0;
  33. }