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
6#define BOOST_THREAD_VERSION 2
7
8#include <iostream>
9#include <boost/thread/thread_only.hpp>
10
11using namespace std;
12using namespace boost;
13
14 struct X {
15 void operator()()
16 {
17 boost::this_thread::sleep(rel_time: posix_time::seconds(2));
18 }
19 };
20int main()
21{
22 X run;
23 boost::thread myThread(run);
24 boost::this_thread::yield();
25 if(myThread.timed_join(rel_time: posix_time::seconds(5)))
26 {
27 cout << "thats ok";
28 return 0;
29 }
30 else
31 {
32 cout << "too late";
33 return 1;
34 }
35}
36

source code of boost/libs/thread/test/test_5891.cpp