C++
Email
Discuss
Print
Reprint

add to:
Del.icio.us
Digg
Google
Spurl
Slashdot
Y! MyWeb
Blink
Furl
April 15, 2003

The Boost.Threads Library

(Page 7 of 7)
May 2002/The Boost.Threads Library/Listing 6

Listing 6: A very simple use of boost::call_once

#include <boost/thread/thread.hpp>
#include <boost/thread/once.hpp>
#include <iostream>

int i = 0;
boost::once_flag flag =
  BOOST_ONCE_INIT;

void init()
{
  ++i;
}

void thread()
{
  boost::call_once(&init, flag);
}

int main(int argc, char* argv[])
{
  boost::thread thrd1(&thread);
  boost::thread thrd2(&thread);
  thrd1.join();
  thrd2.join();
  std::cout << i << std::endl;
  return 0;
}
— End of Listing —
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7


Please log in to post comments.
DR. DOBB'S CAREER CENTER
Ready to take that job and shove it? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:



    INFO-LINK
     


    MARKETPLACE
    Ensure global WAN & LAN network availability
    Find out how to ensure global WAN and LAN network availability for all networked financial and banking applications across distributed organizations. Free white papers from NetScout.
    Align Business Costs with Usage.
    Connect with IBM Business Partners delivering Software as Services solutions to meet your business and IT needs.
    Keep your Network Running!
    Build an Environment with Enhanced Security & Resilience with IBM.
    Your Applications Mean Business!
    IBM can help your company deliver greater business value. Click to learn how and download complimentary reports from IBM.
    IT Sales Lead Follow Up
    Fast and acurate IT lead qualification from websites, trade shows, direct mail, trade advertising or any other marketing sources. Don't let good leads die young. SSM: Strategic Sales & Marketing. Technology Lead Generation: Since 1989

    |
    SDMG Websites: BYTE.com, DotNetJunkies, MSDN Magazine, Sys Admin, SD Expo, SqlJunkies, TechNet Magazine, Unixreview