References in Java and JNI (strong, soft, weak, virtual)

1. Strong References (Objects) Features: Strong references provide direct access to the target object. Will not be recycled. Two, soft reference (SoftReference class) Features: When GC reclaims based on JVM memory, JVM reclaims when it finds it is out of memory Conditions for freeing up space: JVM found insufficient m ...

Added by trygve on Sun, 19 Jul 2020 18:32:41 +0300

Coexistence of Kotlin and Java, calling kotlin code in -Java

Call of kotlin data class Call of object simple profit mode class in Kotlin Calling file class in Kotlin Flexible transfer of parameters by calling jvm annotation String string null call Call of kotlin data class kotlin Code: package com.tianfu.kotlin /** * age Member annotations cannot have get and ...

Added by beezza on Wed, 08 Jul 2020 19:00:57 +0300

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