Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/thread/example/thread_group.cpp @ 45

Last change on this file since 45 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 599 bytes
Line 
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
7#include <boost/thread/thread.hpp>
8#include <iostream>
9
10int count = 0;
11boost::mutex mutex;
12
13void increment_count()
14{
15    boost::mutex::scoped_lock lock(mutex);
16    std::cout << "count = " << ++count << std::endl;
17}
18
19int main(int argc, char* argv[])
20{
21    boost::thread_group threads;
22    for (int i = 0; i < 10; ++i)
23        threads.create_thread(&increment_count);
24    threads.join_all();
25}
Note: See TracBrowser for help on using the repository browser.