当前位置:网站首页>[QT] for multithreaded programs, do not use the printf() function to print out
[QT] for multithreaded programs, do not use the printf() function to print out
2022-06-25 05:32:00 【qilei2010】
I happened to see in the book , I feel this is a hidden knowledge point , It's easy to get into it by mistake , But no reason , It is recorded here , Help beginners to put into the pit .
according to 《Qt5 Development and examples 》( Electronic industry press ,ISBN:978-7-121-36157-9) Book No 299 page , speak of :
The thread will call printf() Function to hold a control I/O Lock of (lock), Multiple threads call printf() Function will block console output in some cases , While using Qt Provided qDebug() Function as console output will not cause the above problem .
It means If each thread uses printf() Normalization of functions , In fact, each thread of the whole program is Use the same I/O process , So it will cause resource preemption and process mutual exclusion . While using qDebug() Will not be .
take printf(yourVar) function Replace with qDebug()<< yourVar , Also remember to add the header file reference :include <QtDebug>
QString hello = "hello world";
printf("%s", hello);Change it to :
#include <QtDebug>
QString hello = "hello world";
qDebug()<<hello;in addition :
《Qt5 Development and examples 》( Electronic industry press ,ISBN:978-7-121-36157-9) The book is very good , Suitable for manual translation , If you want to use it Qt, This book is very suitable for reference .
边栏推荐
- Penetration test - right raising topic
- Basic bit operation symbols of C language
- Pointer array function combination in C language
- DOM document object model (I)
- About the definition of pointer variables (personal notes)
- Monkey test of APP automation
- Instant messaging project (I)
- Voxel based and second network learning
- Uva1103 ancient pictograph recognition
- Go Concurrency
猜你喜欢

Detailed summary of flex layout

TX Text Control 30.0 ActiveX

MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code

Everything is an object

Array and simple function encapsulation cases

Flex flexible layout for mobile terminal page production

CTFHub-rce

Small sample learning data set

Create an environment for new projects

SQL lab range explanation
随机推荐
H5 native player [learn video]
DOM document object model (I)
Pointer array function combination in C language
Eyeshot Ultimate 2022 Crack By Xacker
Even if you are not good at anything, you are growing a little bit [to your 2021 summary]
About the definition of pointer variables (personal notes)
CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
Enhanced paste quill editor
Learn the interface test, see it is very good, and make a note
Makefile Foundation
Detailed summary of position positioning
Monkey test of APP automation
Customize the console plot result style
February 19 CTF exercise
Basic bit operation symbols of C language
IronOCR 2022.1 Crack
JSON Library Tutorial from scratch (I): starting to learn and organize notes
Can bus extended frame
Dynamic programming example 1 leetcode 322 coin change
Array and simple function encapsulation cases