[c++11 concurrent programming] 01-hello World

Source: Internet
Author: User

The C++11 standard supports concurrency, which includes features such as thread management, shared resource protection, inter-thread synchronization operations, and underlying atomic operations. Let's start with a simple example of how the C++11 standard multithreaded program is.

#include <iostream> #include <thread>//refers to the header file of the class that manages the thread using namespace std;//the entry function of the thread, the program prints in the newly created thread logvoid Hello () {cout << "Hello Concurrent World" << Endl;} int _tmain (int argc, _tchar* argv[]) {//Construct thread object T, set function Hello for its entry function, thread t (hello);//thread t is created, the main thread continues execution, and the child thread is added to the main thread. The main thread will then wait for the child thread to end//otherwise, the main thread may exit T.join () before the child thread ends; return 0;}

Program execution Results:


[c++11 concurrent programming] 01-hello World

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.