A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/thread.htm below:

C++ Standard Library Thread

C++ Library - <thread> Introduction

Thread is a sequence of instructions that can be executed concurrently with other such sequences in multithreading environments, while sharing a same address spac.

Member types Sr.No. Member type & description 1 id

It is a thread id.

2 Native handle type

It is a native handle type.

Member functions Non-member overloads Sr.No. Non-member overload & description 1 swap (thread)

It is used to swap threads.

Example

In below example for std::thread.

#include <iostream>
#include <thread>

void foo() {
   std::cout << " foo is executing concurrently...\n";
}

void bar(int x) {
   std::cout << " bar is executing concurrently...\n";
}

int main() {
   std::thread first (foo);
   std::thread second (bar,0);

   std::cout << "main, foo and bar now execute concurrently...\n";

   first.join();
   second.join();

   std::cout << "foo and bar completed.\n";

   return 0;
}

The output should be like this −

main, foo and bar now execute concurrently...
 bar is executing concurrently...
 foo is executing concurrently...
foo and bar completed.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4