|
|||
|
ABOUT US |
CONTACT |
ADVERTISE |
SUBSCRIBE |
SOURCE CODE |
CURRENT PRINT ISSUE |
FORUMS
|
NEWSLETTERS
|
RESOURCES
|
BLOGS
|
PODCASTS
|
CAREERS
|
|||
April 15, 2003
The Boost.Threads Library
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
Please log in to post comments.
|
|
|||||||||||||||||||||||
|
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 |
|