The first thread in C++11

Gioacchino Lonardo
1 min readOct 1, 2018

The C++ language with its Standard Library makes thread management very simple. Many aspects of competition are handled through std::thread.

Every C++ program has at least one thread

This thread is started by C++ runtime and the latter is called “main”. It doesn’t matter what the thread is going to do or where it is launched from, but running a thread using the C++ Thread Library always reduces itself to building a std::thread object.

Hello world

We will see the example run on an online IDE, so you can see the effect of the execution.

The functions and classes for managing threads are declared in <thread>. Every thread have an initial function, which is where the new thread of execution begins. In this case the std::thread object name is y and has the new function hello() as its initial function.

On Online IDE press RUN!

https://onlinegdb.com/B1lrSwy9Q

--

--

Gioacchino Lonardo

Computer Engineer, AI enthusiast, biker, guitar&bass player