Design mode - singleton mode
Singleton mode
1. Overview of singleton mode
For some classes of a software system, only one instance is very important. For example, a system can only have one window manager or file system, only one timing tool, etc.
How to ensure that a class has only one instance and that the instance is easy to access? Defining a unified global variable ...
Posted by mickro on Wed, 09 Feb 2022 17:57:53 +0100
Low cost timestamp acquisition
This article has been included https://github.com/lkxiaolou/lkxiaolou Welcome, star.
preface
In the previous article Design and implementation of Cobar SQL audit A question about the performance of timestamp acquisition is raised in
Get the operating system time, and directly call system in Java currentTimeMillis(); It's OK, but in Cob ...
Posted by bryan52803 on Wed, 09 Feb 2022 17:50:21 +0100
Spring's @ Async annotation implements asynchronous methods
@Async annotationSpring 3 began to provide @ Async annotation, which can be marked on methods or classes, so as to facilitate the asynchronous invocation of methods. The caller will return immediately when calling the asynchronous method, and the actual execution of the method will be submitted to the thread execution in the specified thread po ...
Posted by rnintulsa on Wed, 09 Feb 2022 12:45:03 +0100
Implementation of singleton mode
1, What is singleton mode
Singleton Pattern is one of the simplest design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects.
This pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object is created. This class prov ...
Posted by bigphpn00b on Wed, 09 Feb 2022 07:54:21 +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
Read write lock analysis
Tip: after the article is written, the directory can be generated automatically. Please refer to the help document on the right for how to generate it
preface
Multithreading is one of the cores of java. As a java Engineer, you must understand multithreading thoroughly!
Tip: the following is the main content of this article. The follo ...
Posted by franklyn on Tue, 08 Feb 2022 12:41:15 +0100
QThread of Qt multithreading
In the project, a QThread object manages a thread. Generally speaking, the execution of a thread starts with the run () function. In Qt, there are two ways. The first is to inherit QThread and rewrite run() function. The second is to inherit QObject function and add time-consuming operations, and then call QObject::moveToThread() function. It i ...
Posted by deolsabh on Tue, 08 Feb 2022 04:47:49 +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
Immutability of java Concurrent Programming sharing model
preface
Start with (6) and discuss some immutable classes. The article is based on the book "the art of Java Concurrent Programming" and the video of dark horse Dark horse multithreading Take notes.
1. Date conversion
For the date class SimpleDateFormat, since SimpleDateFormat is not thread safe, exceptions may occur in the ...
Posted by bynary on Fri, 04 Feb 2022 09:25:28 +0100
[Socket and IO framework learning] 3 NiO (non blocking IO) Basics
[Socket and IO framework learning] 3 NiO (non blocking IO) Basics
I haven't seen this thing for nearly half a month, and I have nothing to do today. I continue to record the learning NIO. This N represents "new". According to my Baidu, NIO was introduced in the version of jdk 1.4 to make up for the shortcomings of the original I/O ...
Posted by burfo on Thu, 03 Feb 2022 21:12:06 +0100