Exit function

Time:2020-11-25

Referring to the relevant information, calling the exit function directly returns the process to the operating system, whether it is invoked in the main thread or the child thread, will directly control the control to the operating system.

 

 

Code 1: call exit in main thread to exit.

#include 
#include 

using namespace std;

void thread_fun()
{
    cout<

The output is as follows:

 

 

 

Code 2: call exit function in sub thread

#include 
#include 

using namespace std;

void thread_fun()
{
    cout<

The output is as follows:

 

It can be seen that after calling the exit function in the sub thread, the whole program is all out, including the child thread.

 

Recommended Today

The course of using Chinese software of poedit Pro

Poedit pro (formerly known as poedit) is a free (professional version charge), open source and cross platform gettext class (. Po format, gettext is used in the application program for program internationalization) International Translation editor. It is also one of the most widely used software of the same type. At present, it is available in […]