Gold 3: rain and dew - don't let your thread starve to death in the competition

Welcome to< Concurrent King class >, this article is the 13th in this series. In the last article, we introduced several strategies to avoid deadlock. Although deadlock is notorious, in concurrent programming, in addition to deadlock, there are some equally important thread activity issues that deserve attention. Their popularity is not ...

Posted by php_novice2007 on Sun, 30 Jan 2022 00:21:20 +0100

A simple database connection pool implementation

Wait timeout mode When calling a method, wait for a period of time. If the method can get the result within a given period of time, the result will be returned immediately. On the contrary, the timeout will return the default result. Assuming that the timeout period is T, it can be inferred that the timeout will occur after the current time n ...

Posted by mmoranuk on Fri, 28 Jan 2022 23:55:54 +0100

ThreadLocal - in depth analysis of interview questions

Original address ThreadLocal brief introduction ThreadLocal is a local thread copy variable utility class. It is mainly used to map the private thread and the copy object stored by the thread. The variables between threads do not interfere with each other. In high concurrency scenarios, stateless calls can be realized. It is especially suitab ...

Posted by chadtimothy23 on Wed, 26 Jan 2022 10:58:29 +0100

java high concurrency Semaphore (Semaphore)

semaphore Pronunciation: English[ ˈ sem ə f ɔː ®] Beauty[ ˈ sem ə f ɔː r] Semaphore (semaphore) provides a more powerful control method for multi-threaded cooperation, synchronized and reentrant lock. These two locks can only allow one thread to access one resource at a time, and semaphore can control how many threads can access specific ...

Posted by sunder on Tue, 25 Jan 2022 13:03:32 +0100

The first lock of Java people -- synchronized

Wedge In the last article, we learned the volatile keyword. In this article, we continue to learn another keyword commonly used in concurrent programming - synchronized. synchronized usage First, let's look at several common ways to use synchronized. Use synchronized(this) to decorate code blocks class SyncThread implements Runnable { ...

Posted by Stephen on Mon, 24 Jan 2022 11:30:37 +0100

Multithreading: producers and consumers

catalogue Producer and consumer model Overview of producer and consumer models [application] Producer and consumer case [application] Producer and consumer case optimization [application] Basic use of blocking queue [understanding] Blocking queue realizes waiting wake-up mechanism [understanding] Producer and consumer model Overview ...

Posted by abhi201090 on Mon, 24 Jan 2022 03:18:39 +0100

JUC concurrent programming -- ForkJoin mode

catalogue 1, What is ForkJoin 2, ForkJoin is easy to use 3, ForkJoin principle Core API Job theft algorithm ForKJoin principle 1, What is ForkJoin "Divide and conquer" is an idea. The so-called "divide and conquer" is to divide a complex algorithm problem into several smaller parts according to a certain "dec ...

Posted by emdee on Sun, 23 Jan 2022 11:53:32 +0100

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

Problems of concurrent programming

The purpose of concurrent programming is to make the program run faster, but it is not to start more threads to maximize the concurrent execution of the program. In concurrent programming, if the program runs faster through multithreading, it will face many problems, such as context switching, deadlock, and resource problems limited by h ...

Posted by aa-true-vicious on Sat, 22 Jan 2022 17:38:25 +0100

JUC concurrent programming

Thread six states New: a new thread object has been created, but the start() method has not been called yet.Runnable: the two states of ready and running in Java threads are generally called "running". After the thread object is created, other threads (such as main thread) call the start() method of the object. The thread in ...

Posted by loquaci on Sat, 22 Jan 2022 02:45:46 +0100