Multithreading and Multiprocessing in Python Concurrency Programming

Concurrency refers to the ability of a program to handle multiple tasks simultaneously. In Python, the two core methods for achieving concurrency are multithreading and multiprocessing. Although both can execute tasks “in parallel”, their underlying implementations and applicable scenarios are quite different, with the key difference being the memory space isolation between processes and threads.Multithreading … Read more

A Concise Guide to C++ std::atomic

When it comes to thread safety in multithreaded programming, many people’s first reaction islocks (mutex)πŸ”’. For example, with a counter, some threads are incrementing while others are decrementing. To prevent multiple threads from operating simultaneously, we can use locks for protection. But is using a lock for a counter a bit too costly? Is there … Read more

A Trio of Concurrency in Rust: Join, Arc, and mpsc Channel Synchronization in Practice

A Trio of Concurrency in Rust: Join, Arc, and mpsc Channel Synchronization in Practice

A Trio of Concurrency in Rust:<span>Join</span>、<span>Arc<Mutex></span> and <span>mpsc</span> Channel Synchronization in Practice Concurrency is one of Rust’s core advantages, but handling shared state and thread communication has always been a challenge in programming. Rust, with its ownership system and unique synchronization primitives, makes multithreaded programming safe and efficient, completely eliminating common issues like data races … Read more

Design of a General-Purpose Multithreading Middleware in Qt C++

Design of a General-Purpose Multithreading Middleware in Qt C++

For multithreading collaborative scenarios, design ageneral-purpose multithreading middleware that supports thread state management (initialization β†’ startup β†’ running β†’ waiting β†’ stopping), dependency awareness, ordered switching, and error handling. Below is the complete implementation plan. The design goals of the middleware — High versatility: Adapt to various types of threads, reducing expansion costs Versatility: Supports … Read more

What is the Use of ‘volatile’ in C Language?

What is the Use of 'volatile' in C Language?

Hello everyone, I am Xiao Feng Ge. When learning C language, there is a strange keyword volatile, what is its use? volatile and the Compiler First, let’s look at this piece of code: int busy = 1; void wait() { while(busy) { ; }} Compile it, and note that O2 optimization is used here:Let’s take … Read more

What is the Use of ‘volatile’ in C Language?

What is the Use of 'volatile' in C Language?

Code Xiaobian MillionFans CertifiedAccount By clicking follow, you not only gain a tool for finding resources but also an interesting soul β–Ά β–Ά β–Ά When learning C language, there is a strange keyword ‘volatile’. What is its use? volatile and the Compiler First, let’s look at this piece of code: int busy = 1; void … Read more

C++ Learning Manual – Multithreading and Concurrency 54 – Asynchronous Programming (std::future, std::async)

C++ Learning Manual - Multithreading and Concurrency 54 - Asynchronous Programming (std::future, std::async)

In the previous chapters, we learned how to explicitly create and manage threads using <span>std::thread</span>. This is a powerful and straightforward method, but it can sometimes feel cumbersome. Often, we just want to execute a task asynchronously and retrieve its result at some point in the future without manually handling the tedious details of thread … Read more

The Truth Behind C++ Multithreading Vulnerabilities: 90% of Developers Are Unaware!

The Truth Behind C++ Multithreading Vulnerabilities: 90% of Developers Are Unaware!

C++ multithreading programming has always been a highly technical topic. It can bring significant performance improvements, but improper handling of details can lead to serious issues. With the popularity of multi-core processors, many developers choose to introduce multithreading to optimize program performance when facing compute-intensive tasks. However, C++ multithreading programming is not as simple as … Read more

What is the Difference Between Multithreading and Multiprocessing in Embedded Linux?

What is the Difference Between Multithreading and Multiprocessing in Embedded Linux?

Multiprocessing Multiprocessing, also known as processes, refers to independent programs running in their own memory space. Each process has its own address space, code, data, and stack. Communication between processes requires IPC mechanisms (pipes, message queues, shared memory, sockets). When to Use? You want isolation (one process crashing does not affect other processes). Embedded example: … Read more

Debugging C++ Multithreaded Programs with GDB

Debugging C++ Multithreaded Programs with GDB

We are currently in a multi-core era, and multithreaded programs are very common. This article will explore how to debug C++ multithreaded programs. Example Code This article designs a demo multithreaded program where the main thread starts two business threads that execute the functions business_1 and business_2. Each of these functions defines a counter object … Read more