1 // Copyright (C) 2001-2003
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)
7 #include <boost/thread/recursive_mutex.hpp>
8 #include <boost/thread/thread.hpp>
14 counter() : count(0) { }
17 boost::recursive_mutex::scoped_lock scoped_lock(mutex);
22 boost::recursive_mutex::scoped_lock scoped_lock(mutex);
27 boost::recursive_mutex mutex;
35 std::cout << "count == " << c.increment() << std::endl;
38 int main(int, char*[])
40 const int num_threads=4;
42 boost::thread_group threads;
43 for (int i=0; i < num_threads; ++i)
44 threads.create_thread(&change_count);