Talking about volatile in Java
Memory visibility
Volatile is a lightweight synchronization mechanism provided by Java. It also plays an important role in concurrent programming. Compared with synchronized (usually called heavyweight lock), volatile is more lightweight. Compared with the huge overhead brought by using synchronized, if volatile can be used properly and reason ...
Added by gassaz on Fri, 24 Dec 2021 12:16:05 +0200
JAVA Concurrent Programming -- Introduction and use of Future and completable Future
1. Introduction to future2. Use of future class3. Introduction to completabilefuture class4. Use of completabilefuture class5. Summary 1. Introduction to futureWe were in this article before JAVA Concurrent Programming -- Introduction and use of Callable interface and FutureTask As mentioned in, Future is an asynchronous processing thread class ...
Added by localhost1 on Fri, 24 Dec 2021 07:12:28 +0200
JavaSE advanced multithreading -- thread collaboration
Thread collaboration
Thread communication
Application scenario: producer and consumer issues
Suppose that only one product can be stored 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 wi ...
Added by doni49 on Fri, 24 Dec 2021 04:00:15 +0200
Ali was asked about the Java ThreadPool thread pool on both sides. After reading this article, he angered the interviewer
Advantages of thread pool
The work done by the thread pool is mainly to control the number of running threads, put tasks into the queue during processing, and then start these tasks after threads are created. If the number of threads exceeds the maximum number, the exceeded threads queue up, wait for other threads to complete execution, and ...
Added by sectachrome on Thu, 23 Dec 2021 23:05:23 +0200
Teach you how to use Python web crawler to send mail regularly (with source code)
Hello, I'm meow in the IT industry.
preface
A few days ago, a big man shared a code to grab the reading directory and send emails regularly in the group. I feel it's quite good. I'll share it here for you to learn.
1, Train of thought
The idea is not difficult. Construct a crawler task, grab the directory on a book website, then return the ...
Added by doublehops on Thu, 23 Dec 2021 22:48:12 +0200
Java multithreading (detailed notes)
introduction
It records the concept of multithreading, inheriting Thread, realizing Runnable, Thread sleep, Thread safety problems and solutions, multithread communication problems and Thread pool.
Overview of multithreading technology
Threads and processes
process
It refers to an application running in memory, and each process has an inde ...
Added by MrKaraokeSteve on Thu, 23 Dec 2021 20:31:10 +0200
CompletableFuture (Asynchronous Programming)
Origin of CompletableFuture
CompletableFuture implements the CompletionStage interface, which is an extension of the Future interface. It adds asynchronous callbacks, streaming processing, and the ability to combine multiple Futures to make Java easier to handle multitask collaborative work.
Code examples (1)
thenCombine
public class F ...
Added by homerjay on Thu, 23 Dec 2021 13:02:54 +0200
BIO and NIO summary
BIO and NIO
Note: the io models discussed in this paper are based on the network communication socket
BIO -- blocking IO model
In network communication, the client establishes a connection with the server first. Because the server does not know when the client will send data, the server has to start a thread to receive messages from the clie ...
Added by kumaran on Thu, 23 Dec 2021 11:51:58 +0200
1. Concept and thread creation
concept
Program: an ordered collection of instructions and data. It has no meaning of running. It is a static concept
Process: an execution process of a program. It is a dynamic concept with its own life cycle. It is the basic unit of system resource allocation
Thread: it is the basic unit of CPU scheduling and execution
When a program ...
Added by paqman on Thu, 23 Dec 2021 05:52:12 +0200
Management of multithreaded learning note sharing model
3.1. Analysis of thread shared variables
Two threads do self increment and self decrement for static variables with an initial value of 0 for 5000 times respectively. Is the result 0?
static int counter = 0;
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(() -> {
f ...
Added by Stole on Thu, 23 Dec 2021 01:12:33 +0200