QReadWriteLock  This allows multiple processes to read at the same time , But only one wrote . And writing and reading can't be done at the same time .
The document is vague , This is my own understanding :
lockForWrite  Lock for writing , It's about modifying the data , Outsiders can't even come in and read the data , Completely monopolize the right to use data .
lockForRead Lock for reading , That is, do not modify the data during reading , But if others ask to read the data , We don't refuse . But someone else changes the data , I'll wait until I finish reading the data .
 
QReadWriteLock lock;
 
void write()
{
lock.lockForWrite();// Lock for writing
..........
lock.unlock();// Unlock
}
 
void read()
{
lock.lockForRead();// Lock for reading
..............
lock.unlock();// Unlock
}

QReadWriteLock More about the difference between read and write locks

  1. QReadWriteLock A little test of read-write lock ( It's a logical lock , It's not related to the real thing ), The only way to do this is to lock up the reading , To read it again , Otherwise, it will not be allowed at all

    QReadWriteLock m_lock; void MyWidget::Button1(){ m_lock.lockForRead(); ShowMessage(tr("111" ...

  2. OS | Read-write lock 【 pick 】

    Read write lock is used to solve the problem of readers and writers , Read operations can be shared , The writing operation is exclusive , There can be more than one reading , Only one is writing , When writing at the same time, reading is not allowed . The difference between a mutex and a read-write lock : When accessing critical resources ( The meaning of access includes all operations : Read and write ...

  3. Linux Use of read-write lock

    Read write lock is used to solve the problem of readers and writers , Read operations can be shared , Write operations are exclusive , There can be more than one reading , Only one is writing , You are not allowed to read while writing . It has two forms: strong reader synchronization and strong writer synchronization : Strong reader synchronization : When the writer is not writing , Readers ...

  4. pthread_rwlock_t Read write lock function description

    Read-write lock Indexes : Initialize a read-write lock pthread_rwlock_init Read lock read write lock      pthread_rwlock_rdlock Non blocking read lock pthread_rwlock_tryrdloc ...

  5. Read-write lock pthread_rwlock_t Use ( turn )

    Read write lock is used to solve the problem of readers and writers , Read operations can be shared , The writing operation is exclusive , There can be more than one reading , Only one is writing , When writing at the same time, reading is not allowed . It has two forms: strong reader synchronization and strong writer synchronization Strong reader synchronization : When the writer doesn't write , Readers ...

  6. C# Read-write lock ReaderWriterLockSlim Use

    The concept of a read-write lock is simple , Allow multiple threads to acquire read lock at the same time , But only one thread is allowed to acquire a write lock at the same time , So it's also called sharing - An exclusive lock . stay C# in , Recommended ReaderWriterLockSlim Class to complete the function of read-write lock . In some cases , Yes ...

  7. linux Use a read-write lock pthread_rwlock_t

    from :http://blog.csdn.net/onlyou930/article/details/6755593 Use a read-write lock After configuring the properties of the read-write lock , To initialize the read-write lock . The following functions are used to initialize or destroy read-write locks . ...

  8. java Multithreading : Under contract ReentrantReadWriteLock The principle of read-write lock

    One : Read write lock solves the problem of scene ---> The frequency of reading data is much higher than that of writing data , You can use a read-write lock . Two : The structure of the read-write lock ---> use state A variable . Convert it to binary , front 16 The bit is high , Mark the number of times the read thread acquires the lock ...

  9. Read-write lock ReaderWriterLockSlim

    The concept of a read-write lock is simple , Allow multiple threads to acquire read lock at the same time , But only one thread is allowed to acquire a write lock at the same time , So it's also called sharing - An exclusive lock . In some cases , The number of times an object is read is much greater than the number of times it is modified , If it's just a simple use lock Way lock , It will affect reading ...

Random recommendation

  1. Write your own from scratch C# frame (20)—— Framework exception handling and logging

    Very busy recently , There's a lot of chores , So the development of this framework is also intermittent , Finally in the first two days will be set in front of the functions are basically completed , The rest of the small function missing later found to add . The following chapters mainly explain the development process based on this framework . There are four parts in this framework ...

  2. Altium Desiner Warning adding hidden net

    This is because Some components Hide the vcc GND Or not using vcc GND , You don't have to call the police . I can put vcc GND Delete this pin .

  3. PIC32MZ tutorial -- Blinky LED

    Today I finish the "Blinky LED" application on PIC32MZ starter kit. This application let L ...

  4. POJ 3416 Crossing

    Tree array + Offline operation #include<stdio.h> #include<string.h> #include<math.h> #include<algori ...

  5. ADB shell appear error:device offline Tips

    terms of settlement : 1.adb kill-server 2.adb start-server 3.adb remount Execute this 3 Give me a command and retype adb shell It should be ok

  6. hibernate-- Many to many bidirectional association ( To use less )

    The teacher knows which students he has taught , Students also know which teachers are teaching themselves . Teacher.java: package com.bjsxt.hibernate; import java.util.HashSet; i ...

  7. Undefined index: HTTP_RAW_POST_DATA Solutions for

    $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; Replace with $postStr = isset($GLOBALS['HTTP_RAW_POST_DA ...

  8. Servlet The best way to read a file

    stay java web It is inevitable to read the text information when developing , But in a different way , The price is also different , I learned a good practical skill today , Let me share with you . Read property configuration file It's read property (pro ...

  9. ansible in include_tasks and import_tasks

    brief introduction This article mainly summarizes the following ansible in task What are the methods called and the main differences between them ​ With more and more services to manage , We're not going to task Put it in roles in , Will find playbook The files are getting bigger , More and more content , Manage ...

  10. boost::bind Introduce

    boost::bind Introduce   This article introduces boost::bind() Usage of , The main content of the article is reference boost Documents . 1. Purpose boost::bind yes std::bindlist and std: ...