java thread pool configuration details
java thread pool configuration details
ThreadPoolExecutor full parameter construction
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> work ...
Posted by Accurax on Wed, 05 Jan 2022 06:29:37 +0100
Concurrent programming - immutable object of thread safety policy
Brain map
Four thread safety policies
Thread limit
An object restricted by a thread, which is exclusive to the thread and can only be modified by the thread that owns it
shared read-only
A shared read-only object can be accessed concurrently by multiple threads without additional synchronization, but no thread can modify it
...
Posted by philicious on Wed, 05 Jan 2022 00:40:19 +0100
Thread safety and thread state
1. Thread state
Threads have five statuses: new; be ready; Obstruction; function; death
New state: a new thread state created by the new Thread() method
Ready state: enter the ready state after starting through the start () method. It is not executed immediately and waits for CPU scheduling
Blocking state: use the sleep() method or sy ...
Posted by boofboof on Tue, 04 Jan 2022 22:43:05 +0100
10, Producer consumer issues
1, Producer consumer issues
1. Problems
Suppose that only one product can be put in the warehouse, the producer puts the produced products into the warehouse, and the consumer takes the products from the warehouse for consumptionIf there is no product in the warehouse, the producer puts the product into the warehouse. Otherwise, stop producti ...
Posted by aeshanw on Tue, 04 Jan 2022 16:54:46 +0100
The use of volatile in singleton mode
Singleton mode
The common writing methods of single case mode include lazy mode, hungry mode, double check mode, etc.
Lazy mode is to create objects when you use them.Hungry man mode is a static object that has been loaded in advance.Double check mode is to check twice before and after locking to prevent multiple threads from creating multipl ...
Posted by Alk3m1st on Tue, 04 Jan 2022 07:08:01 +0100
Entry level Python multithreading learning notes
catalogue
1, Multithreading module: threading
Two, module function
1 create thread
2. Start thread
3. Wait for thread
4. Thread lock
5. Number of threads currently alive
Tip: the following is the main content of this article. The following cases can be used for reference
1, Multithreading module: threading
threading module is a ...
Posted by BPWheeler on Mon, 03 Jan 2022 17:58:02 +0100
fork problem under multithreading (simulation and solution)
preface
For the concepts of process, multithreading and fork, please see the two articles I wrote before. Linux: process control (process creation, process termination, process waiting, process program replacement) Linux: detailed explanation of multithreading (thread concept, thread control - thread creation, thread termination, thread wa ...
Posted by slak on Mon, 03 Jan 2022 11:09:55 +0100
Several ways of creating threads in Java
1, Inherit Thread class
The Thread class essentially implements an instance of the Runnable interface. It starts a new Thread by inheriting the Thread class and copying the run method. Calling the start method tells the CPU that the Thread is ready to execute, and then the system will execute its run method when it has time. Directly calling t ...
Posted by tjg73 on Mon, 03 Jan 2022 06:06:26 +0100
Multithreading_ Multi process (python)
Multi process
A running program is called a process
3. Multi process and multi task
3.1 process creation
# 1. Import process package
import multiprocessing
# 2. Create process objects through process classes
Process object = multiprocessing.Process()
# 3. Start the process and perform the task
Process object.start()
3.2 creating proce ...
Posted by jesse_james on Mon, 03 Jan 2022 04:18:12 +0100
Multithreading and high concurrency section 1, summary of classroom knowledge 21.08.01
Understanding concurrency and parallelism
Concurrency refers to the execution of multiple tasks at the same time for a CPU - in essence, it is divided into time slices. Because the time is very short, it gives the impression that it is executed at the same time; Parallel is for multiple CPUs to execute multiple tasks at the same time (one ...
Posted by Ollie Saunders on Sun, 02 Jan 2022 18:20:28 +0100