Šimon Tóth’s Post

View profile for Šimon Tóth

C++ Educational Content Creator | 20 years of Software Engineering experience distilled into digestible daily posts

The C++20 standard introduced a new version of the standard thread handle, std::jthread (joining thread). When an instance of a std::thread is destroyed while holding a thread, it will automatically call std::terminate. We, therefore, have to manually call join() or detach(). The std::jthread will instead automatically join the held thread in its destructor. Compiler Explorer link: https://lnkd.in/dv6dr6NM #cpp #cplusplus #coding #programming #dailybiteofcpp

  • text
Salman Al-Farisy

C++ Dev | Data Entry | E-Commerce Specialist | Head of Warehouse | Admin Warehouse |

1y

How to update g++ to version 20? I have current versiom g++13 ..

Like
Reply

I can never get rid of the feeling that "jthread" sounds like a Java thing 😅

Really interesting, Anthony Williams described this class in his earlier edition of Concurrency in C++ Still reading the book. At that time, it hadn't been added to the standard, was still in boost.

See more comments

To view or add a comment, sign in

Explore content categories