Ticket #38239: main copy.cpp

File main copy.cpp, 700 bytes (added by steenparl@…, 11 years ago)

Simple C++ test on xCode 4.6, OS-X 10.8.2. No log file

Line 
1#include <iostream>
2#include <string>
3#include <boost/thread/thread.hpp>
4
5using namespace std;
6void goodbye()
7{
8    cout << "Goodbye World ";
9    cout <<endl;
10}
11
12void hello(string msg)
13{
14    cout << "Hello World ";
15    cout << msg << ", I am a thread"<<std::endl;
16    cout <<endl;
17    boost::this_thread::at_thread_exit(&goodbye);
18}
19
20int main(int argc, const char * argv[])
21{
22    boost::thread   t(&hello,"from me!");
23    t.join();
24    // insert code here...
25    cout << "Hello again, World!\n"<<endl;
26    return 0;
27
28}
29
30/// OUTPUT:
31/*
32 Hello World from me!, I am a thread
33 
34 Goodbye World
35*/
36/// Program then hangs just before leaving the thread with
37/// Thread2: EXC_BAD_ACCESS(code=1, address=0x19)