MySQL database implements master-master synchronization

Foreword MySQL master-master synchronization actually promotes slave database to master database on the basis of master-slave synchronization, so that they can read and write databases with each other, and slave database becomes master Database; the process of master-slave mutual authorization connection, reading the binlog log of the other party and updating it to the local […]

Passing thread id between MDC and asynchronous multithreading of logs

Article directory 1 MDC 1.1 Introduction 1.2 MDC coordinates and use 1.3 Main method 2 Use between multiple threads 2.1 MDC Tools 2.2 Interceptor definition and configuration 2.3 Use in Java thread pool 2.3.1 Configure thread pool 2.3.2 Using ExecutorCompletionService 2.3.3 Using CompletableFuture 2.4 Use in Spring thread pool 2.4.1 Inherit ThreadPoolTaskExecutor 2.4.2 Configure thread […]

asio(12), asynchronous tcp, udp server

Official website tutorial: asio asynchronous tcp, udp server int main() {<!– –> try {<!– –> asio::io_context io_context; We will first create a server object to accept TCP client connections. tcp_server server1(io_context); We also need a server object to accept UDP client requests. udp_server server2(io_context); We’ve created two io_context objects that do a lot of […]

CompleteFuture failed to execute asynchronously but returned success

CompleteFuture failed to execute asynchronously but returned success 1. Custom thread pool @Configuration public class ThreadPoolConfig {<!– –> public static ThreadPoolExecutor getThreadPoolExecutor() {<!– –> int availableProcessors = Runtime.getRuntime().availableProcessors(); return new ThreadPoolExecutor( availableProcessors, availableProcessors, 0L, TimeUnit. MILLISECONDS, new LinkedBlockingQueue<>(9999), new ThreadFactoryBuilder().setNameFormat(“thread-pool-%d”).build(), new ThreadPoolExecutor. CallerRunsPolicy()); } } Write three simple asynchronous tasks and create an exception when […]

[c++] Asynchronous print service log

Advantages of asynchronously printing logs Log service is a common background service, which usually requires a lot of log output to record various operations and events. During the running of the service, frequently outputting log information will bring a certain performance overhead, reduce the throughput and response speed of the service, and may even cause […]

Spring asynchronous annotation @Async

Spring provides the @Async asynchronous annotation, which can be marked on a method to call the method asynchronously. @Target({ElementType. TYPE, ElementType. METHOD}) @Retention(RetentionPolicy. RUNTIME) @Documented public @interface Async { /** * A qualifier value for the specified asynchronous operation(s). * <p>May be used to determine the target executor to be used when executing * the […]

Springboot custom ThreadPoolTaskExecutor thread pool multi-threaded concurrent execution of asynchronous methods

1. Background Currently, due to work requirements, a large number of Http requests need to be sent. After practice, it takes 6 hours to complete the traversal and sending. If a single-threaded request is sent, the main thread will be blocked. There will be the following problems: The front-end user waits too long for a […]

Java-Concurrency-21-Eight ways to achieve asynchrony

In actual development, many business scenarios need to use asynchrony, so the following eight common asynchronous methods are listed below Asynchronous mode 1: Thread public class AsyncThread extends Thread {<!– –> @Override public void run() {<!– –> try {<!– –> Thread. sleep(3000); } catch (InterruptedException e) {<!– –> throw new RuntimeException(e); } System.out.println(“3333333333333333333”); } public […]

Thread safety – synchronized and volatile

Article directory thread safety 1. What is a thread safety issue 2. Thread unsafe instance Three, thread unsafe reasons to solve 1. Atomicity 1.1 Definition 1.2 Reasons for insecurity 1.3 synchronized keyword 1.4 synchronized feature 1.5 synchronized use 1.6 Modification example 2. Memory visibility 1.1 Example 1.2 Reasons for insecurity 1.3 volatile keyword 1.4 Modified […]