Python Multithreading Basics
Example 1: Basic Thread Creation
import threading
import time
def func01(number):
print("Function func01 start")
time.sleep(2)
print("Function func01 end")
def func02(number):
print("Function func02 start")
time.sleep(2)
print("Function func02 end")
if __name__ == '__main__':
...
Posted on Fri, 22 May 2026 20:08:33 +0000 by mark110384
Java Concurrency Fundamentals and Implementation Details
Thread States in Java
The Thread.State enum defines six states from the Java language perspective:
NEW: Thread created but not yet started.
RUNNABLE: Thread is executing or ready to run.
BLOCKED: Thread is waiting for a monitor lock to enter a synchronized block/method.
WAITING: Thread is waiting indefinitely for another thread to perform a pa ...
Posted on Thu, 21 May 2026 22:11:38 +0000 by webmazter
Deep Dive into Singleton Pattern Implementations
Core Definition and Characteristics
The Signleton design pattern restricts the instantiation of a class to a single object. This architectural approach ensures that only one unique instance exists throughout the application lifecycle. To achieve this, the class manages its own instantiation process and provides a centralized access mechanism fo ...
Posted on Wed, 20 May 2026 05:38:54 +0000 by s1akr
Handling Static Objects and Managing Deadlocks in Multithreaded .NET Applications
Working with Static Objects
When dealing with static data in .NET, there are important considerations for managed threading.
Static Data and Constructors
A key aspect of accessing static data from managed threads involves constructors. The runtime ensures that a class's static constructor completes before any static member is accessed. Threads ...
Posted on Mon, 18 May 2026 07:20:17 +0000 by Naez
Concurrency in Python: Threading and Multiprocessing
The concurrent module in Python facilitates concurrent programming, particularly for task scheduling and managing thread/process pools. Its core component is concurrent.futures, which offers high-level interfaces for handling threads and processes.
Key Methods
submit(fn, *args, **kwargs): Asynchronously submits a task and returns a Future obje ...
Posted on Sun, 17 May 2026 21:35:19 +0000 by allinurl
A Practical Guide to Python Multithreading
target: specifies the function the thread will execute
args: positional arguments passed to the target function (tuple)
kwargs: keyword arguments passed to the target function (dictionary)
name: gives the thread a name
Thread object methods:
start()
join()
run(): the task function is ultimately executed inside the thread's run method
import ...
Posted on Sun, 17 May 2026 18:55:12 +0000 by les4017
Managing QThread References to Avoid Runtime Crashes in PyQt5
When integrating background processing into a PyQt5 application, instantiating QThread inside a local scope—such as a button-click handler—often triggers intermittent crashes or segmentation faults. The underlying cause is Python’s garbage collector reclaiming the QThread wrapper object once the local variable goes out of scope, even though the ...
Posted on Sun, 17 May 2026 07:59:24 +0000 by hessodreamy
Understanding Java Threads: From Basics to Synchronization
Threads are the smallest unit of execution within a process. A process itself is a running instance of a program—when you launch QQ.exe, the static file on disk becomes a dynamic process in memory. Inside that process, threads are the individual paths of execution that share the same address space.
Visualizing Two Threads
public class DualOutpu ...
Posted on Sat, 16 May 2026 05:00:09 +0000 by scheda
Common Lock Strategies and Synchronized Implementation
Common Lock Strategies
Detailed Lock Strategies
1. Pessimistic Lock vs. Optimistic Lock
Criteria: When locking, predict whether the probability of lock contention is high or low.
If the probability is predicted to be high, more work is required, and locking overhead (time, system resources) is larger → Pessimistic Lock
If the probability is pr ...
Posted on Sat, 16 May 2026 00:15:43 +0000 by elenev
Python ThreadPoolExecutor for Concurrent Task Execution
Overview
ThreadPoolExecutor from the concurrent.futures module provides a simple way to run multiple tasks concurrently in Python. It manages a pool of worker threads and distributes tasks across them efficiently.
Three-Step Pattern
# Step 1: Import the executor
from concurrent.futures import ThreadPoolExecutor
# Step 2: Create an executor ins ...
Posted on Thu, 14 May 2026 09:11:54 +0000 by cdherold