Chapter 7 - thread pool of shared model

Chapter 7 - thread pool of shared model Thread pool (key) There are many pooling technologies, such as thread pool, database connection pool, HTTP connection pool and so on. The idea of pooling technology is mainly to reduce the consumption of resources and improve the utilization of resources. Thread pools provide a way to limit and ma ...

Posted by Adam W on Sun, 13 Feb 2022 09:35:03 +0100

What if the List set is unsafe under the condition of multithreading concurrency? The new colleague was directly confused by me

preface Some time ago, a new employee came to the company. He said that the new employee had been outsourcing code for one and a half years before he came to our company. Once I chatted with him about List. I casually asked him how to solve the unsafe multi-threaded concurrency of List collection when outsourcing. Unexpectedly, he looked at me ...

Posted by gdboling on Thu, 10 Feb 2022 13:19:36 +0100

Too fragrant! Finally, Ali Daniel explained Java multithreading performance optimization in 15 minutes

hello everyone! I am an old ape. I love technology. I have been in the Java industry for 7 years and am on the way to learn and share every day! text We use multithreading just to improve performance, but if multithreading is not used properly, not only the performance improvement is not obvious, but also the resource consumption will be grea ...

Posted by davitz38 on Wed, 09 Feb 2022 06:42:43 +0100

Addition and subtraction counters of JUC Toolkit

1. CountDownLatch CountDownLatch is called a subtraction counter. In practical application, according to the explanation of JDK document, there are two scenarios applicable. Usage 1: as a starting gun, one thread holds the starting gun and orders other threads to start at the same time Usage 2 is to observe the start or end time of all t ...

Posted by tomd79 on Tue, 08 Feb 2022 04:13:24 +0100

[concurrent programming] a bounded blocking queue ArrayBlockingQueue based on array structure

What is ArrayBlockingQueue ArrayBlockingQueue is the most typical bounded blocking queue.Internal use of array storage elements!The capacity size needs to be specified during initialization.Using ReentrantLock to achieve thread safety! Applicable scenarios for ArrayBlockingQueue When used in the producer consumer model, ArrayBlockingQueue ca ...

Posted by phpmoron on Fri, 04 Feb 2022 14:51:43 +0100

Optimistic lock and pessimistic lock

1. Optimistic lock Optimistic lock assumes that the data will not generate concurrency conflict under normal circumstances, so when the data is submitted and updated, it will formally detect whether the data has concurrency conflict. If concurrency conflict is found, it will return the user's error information and let the user decide ho ...

Posted by viperfunk on Tue, 01 Feb 2022 22:23:39 +0100

Introduction to JUC programming

preface: In Java, the thread part is a key point. The JUC mentioned in this article is also about threads. JUC is Java util . Short for concurrent toolkit. This is a toolkit for processing threads. JDK 1.5 began to appear. Let's see how it works. 1, volatile keyword and memory visibility 1. Memory visibility: Let's take a look at the followi ...

Posted by RaheimSG on Tue, 01 Feb 2022 09:33:03 +0100

[concurrent programming] lock introduction and atomic class

Various locks Optimistic lock: read more and write less. Always assume the best situation. Every time you go to get the data, you think others will not modify it, so you won't lock it. However, when updating, you will judge whether others have updated the data during this period. You can use the version number mechanism and CAS algorithm. Pes ...

Posted by dcuellar on Mon, 31 Jan 2022 23:54:45 +0100

[Go language practice] 8 Concurrency (basic)

Main contents: Run the program using goroutineDetect and correct competition statusUsing channels to share data 1. Concurrency basis 1.1 concurrency and parallelism Concurrency and parallelism are two different concepts: Parallelism means that programs run simultaneously at any time;Concurrency means that programs run simultaneously in ...

Posted by edzulis on Mon, 31 Jan 2022 23:28:19 +0100

[JAVA core knowledge] 15.3: thread controller Semaphore

brief introduction A thread controller for resource control under multithreading. Much like lock synchronization, the difference between lock synchronization and lock synchronization is that a lock locks a resource, and only one thread can operate the resource at the same time. Semaphore locks a batch of resources. At the same time, only a ...

Posted by manimoor on Mon, 31 Jan 2022 02:37:04 +0100