CountDownLatch, the three powerful tools of Java high concurrency programming foundation

introduction In the previous article, we introduced the Semaphore of AQS , and it should be countdown latch , next. What is CountDownLatch CountDownLatch is implemented through a counter. The initial value of the counter is the number of threads. Every time a thread is executed, the value of the counter will be reduced by 1. When the value ...

Posted by ocpaul20 on Sun, 23 Jan 2022 00:45:22 +0100

(6) Concurrent tool class completable future (asynchronous programming)

CompletableFuture Asynchronization Asynchronization is the basis for the implementation of the parallel scheme. More specifically, it is the basis for the implementation of the core scheme of using multithreading to optimize performance. For example, two serial operations are handed over to a newly created sub thread for execution. The ma ...

Posted by nkyoung1 on Sat, 22 Jan 2022 13:58:18 +0100

An online thread pool task accident

preface RejectedExecutionException exception thrown by thread pool submission task on line That is, the task submission performs the operation of reject policy. Check the business situation and thread pool configuration. It is found that the number of tasks executed in parallel is less than the maximum number of threads in the thread pool. Th ...

Posted by minc on Fri, 21 Jan 2022 04:13:10 +0100

Basic understanding of java multithreading

Reference blog: https://angela.blog.csdn.net/article/details/105625514 1. Processes and threads An application is a process. A process can contain multiple threads. From the operating system level, threads in the same process share the resources of the process, such as memory space and file handle. Threads are lightweight processes in Linux op ...

Posted by Pryach on Thu, 20 Jan 2022 13:03:58 +0100

[learning notes on multithreaded programming 8] thread synchronization using mutex

Statement: This study note is a summary based on the tutorial and combined with your own learning situation. It is not original. If you want to see the original version, please see the C language Chinese network Multithreaded programming (C language + Linux) , the website has many good programming learning tutorials, especially about C language ...

Posted by Atomic Taco on Wed, 19 Jan 2022 11:49:16 +0100

Comprehensive explanation of Java multithreading and multi case

This chapter mainly clarifies multithreading Processes and threads Process is the unit of system resource allocation, and thread is the unit of CPU scheduling and execution There are three ways to create threads Inherit Thread class (not recommended to avoid the limitation of OOP single inheritance) The custom Thread class inherits t ...

Posted by poison on Tue, 18 Jan 2022 19:54:38 +0100

Concurrent programming - threads

Introduction background of thread concept process We have known the concept of process in the operating system before. The program cannot run alone. Only when the program is loaded into memory, the system allocates resources for it, and this executed program is called a process. The difference between a program and a process is that a program ...

Posted by kaimason1 on Tue, 18 Jan 2022 17:23:06 +0100

Seeing that my colleagues are still randomly defining thread pool parameters, I directly encapsulate a thread pool construction tool class

background I believe that many small partners in work will use thread pool, but the definition and use of thread pool is a complex process, because there are as many as 7 thread pool constructors alone, and the definition of each parameter is not a simple basic data structure. Just pass it in directly Therefore, some inexperienced partn ...

Posted by baruch on Mon, 17 Jan 2022 15:08:09 +0100

muduo network library net source code line by line analysis_ one

1 muduo::net::EchoServer class reference Collaboration diagram of EchoServer: [legend] Public member functionEchoServer (EventLoop *loop, const InetAddress &listenAddr)voidstart () Private member functionvoidonConnection (const TcpConnectionPtr &conn)voidonMessage (const TcpConnectionPtr &conn, Buffer *buf, Timestamp time) Pr ...

Posted by timmy0320 on Mon, 17 Jan 2022 14:57:42 +0100

[redis] three ways to implement distributed locks

1, Why use distributed locks When developing applications, if we need multi-threaded synchronous access to a shared variable, we can use the Java multi-threaded processing we learned, and it can run perfectly without bugs! However, this is a stand-alone application, that is, all requests will be allocated to the JVM of the current server, and ...

Posted by harrymanjan on Mon, 17 Jan 2022 11:15:26 +0100