helloworld2.cpp 537 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2001-2003
  2. // William E. Kempf
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/thread/thread.hpp>
  7. #include <iostream>
  8. struct helloworld
  9. {
  10. helloworld(const char* who) : m_who(who) { }
  11. void operator()()
  12. {
  13. std::cout << m_who << "says, \"Hello World.\"" << std::endl;
  14. }
  15. const char* m_who;
  16. };
  17. int main()
  18. {
  19. boost::thread thrd(helloworld("Bob"));
  20. thrd.join();
  21. }