The magic of strong and weak references in java

Preface Under what circumstances might ThreadLocal have a memory leak?If you want to understand the context of this problem, it is essential to look at the source code. After looking at the source code, you find that static class Entry extends WeakReference <ThreadLocal<?> {} is actually used in ThreadLocal, and the puzzle is actually ...

Added by JoeZ on Sat, 27 Jun 2020 22:59:49 +0300

Distributed timing task -- XXL job learning: source code analysis -- actuator startup process

Distributed timing task -- XXL job learning (2): source code analysis -- actuator startup process preface 1, Start of actuator 1.1 analysis of the core class XxlJobSpringExecutor 1.1.1 initJobHandlerRepository() 1.1.2 initJobHandlerMethodRepository() 1.1.3 GlueFactory.refreshInstance(1) 1.1.4 super.start() ...

Added by Azad on Thu, 25 Jun 2020 05:17:05 +0300

[case demonstration] strong reference, soft reference, weak reference and virtual reference of JVM

1. background To understand when objects are recycled, we need to understand the concept of object reference, so we have the following 2. Reference object structure chart in Java 3. Introduction 3.1. What is strong quotation a. When there is not enough memory, the JVM starts to garbage collect. For a strongly referenced object, even if there i ...

Added by chris_2001 on Sun, 21 Jun 2020 08:56:41 +0300

JAVA-IO streaming advanced NIO

NIO Java NIO (New IO) is a new IO API introduced from Java version 1.4. NIO has the same function and purpose as the original IO, but it is used in a totally different way. NIO supports buffer oriented, channel based IO operations. NIO will read and write files in a more efficient way. Main differences ...

Added by Bill H on Tue, 16 Jun 2020 10:48:24 +0300

Java ticket selling task_ Detailed implementation of multithreading

Java ticket selling task_ Detailed implementation of multithreading Title Review: the Ministry of Railways has issued a ticket sales task, which requires 1000 tickets to be sold and three windows to be sold. Please write a multi-threaded program to simulate this effect. i. window 001 is selling ticket 1000 ii. Window 001 is selling ticket ...

Added by JustLikeIcarus on Sun, 14 Jun 2020 11:38:42 +0300

java Basics - day09_ Byte stream, character stream

Article catalog 02_IO overview (concept & classification) 03_ Everything is byte 04_ Byte output stream_ OutputStream class & introduction to fileoutputstream class 05_ Byte output stream writes data to file 06_ The principle of file storage and notepad opening 07_ The method of writing multi ...

Added by jiggaman15dg on Sun, 14 Jun 2020 07:51:46 +0300

[JVM Story] The Birth of a Java Byte Code File

Long text in thousands of words, completely fictitious.   (1)   An intern came to the group. After Li Dafang finished, he felt his level was average, but he still stayed. Why?Let's guess.Li Da-fat also enlightened himself in his heart. Students should not ask too much, as long as they are willing to go up and slowly.Just call it Xiao Bai.Xi ...

Added by Kingw on Fri, 05 Jun 2020 03:51:28 +0300

HashMap: Source code (constructor, put, resize, get, remove, replace)

1. Constants (1) Default table size, 1 shifts left four bits to 8 static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 (2) Maximum table length static final int MAXIMUM_CAPACITY = 1 << 30; (3) Default load factor size: static final float DEFAULT_LOAD_FACTOR = 0.75f; (4) Tree threshold static final int TREEIFY_ ...

Added by defect on Thu, 04 Jun 2020 07:52:52 +0300

One Day Pattern - Prototype

I. Concepts of Prototype Patterns Prototype Pattern is used to create duplicate objects while maintaining performance.This type of design pattern is creative and provides the best way to create objects. 2. When to use the prototype mode The prototype pattern can be understood as: using a class as a template, cloning out an infinite nu ...

Added by scross on Tue, 19 May 2020 20:02:22 +0300

18 examples take you to master Java 8 date time processing!

Author: Pang xiansen https://juejin.im/post/5a795bad6fb9a0634f407ae5 Java 8 introduces a new date time API. In the tutorial, we will learn how to use the new API through some simple examples. The way Java deals with date, calendar and time has always been criticized by the community. Setting java.util.Date as a variable type and the non thre ...

Added by matthewc on Wed, 06 May 2020 08:54:37 +0300