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 ...

Posted by alireza on Sun, 19 Jul 2020 08:34:35 -0700

Single Case Mode Static Internal Class Resolves Reflection to Get Multiple Objects

First of all, there is no single pattern of hungry Han, lazy, if you need Baidu A little better than the Hungry Han style is the static inner class singleton Paste code here package com.test; public class SimpleTest { private static class SimpleNB { private static final SimpleTest INSTANCE = new SimpleTest(); } private SimpleT ...

Posted by sajlent on Tue, 14 Jul 2020 07:26:20 -0700

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 ...

Posted by denoteone on Wed, 08 Jul 2020 09:03:14 -0700

java packing and unpacking

java packing and unpacking Packing Unpacking Do an experiment Packing Basic data type = > wrapper class For example, int = > integer Unpacking Wrapper class = > basic data type For example, integer = > int Why are there basic data types? Because in java, a new object is stored in t ...

Posted by cowboy_x on Mon, 29 Jun 2020 01:40:14 -0700

Four ways to create singleton pattern

This is a question for my recent interview There are several ways to create a single example of the interviewer's question. I answered the lazy man and the hungry man. He told me that there are two kinds. In fact, I still vaguely remember two kinds. I just can't remember, and my heart silently tears.... ...

Posted by Birdmansplace on Sun, 28 Jun 2020 22:54:54 -0700

Definition of Java annotation

Define annotation syntax @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface MyAnnotation { String className() default ""; String methodName(); } @Target annotation description @Target is the location restriction for annotation, and the ...

Posted by girlzz on Sat, 27 Jun 2020 22:26:18 -0700

Deep understanding of the synchronized underlying source code is enough for beginners

Deep understanding of synchronized underlying source code preface This article analyzes the implementation logic of synchronized from the JVM source code, so as to better understand the depth of synchronized. Process: the basic unit of operating system resource allocation. Thread: the basic unit of ...

Posted by azaidi7 on Thu, 25 Jun 2020 21:55:14 -0700

Understanding the preclean phase of CMS recycler

In "deep understanding of Java virtual machine: advanced features and best practices of JVM (version 2)", the working process of CMS collector is introduced as follows: CMS collector is based on the "mark clear" algorithm. Its operation process is more complex than the previous coll ...

Posted by Muncey on Thu, 25 Jun 2020 03:21:57 -0700

1, Singleton mode - 6 implementations

Design pattern 1, Singleton mode characteristic: A singleton class can only have one instance A singleton class must create its own unique instance Singleton classes must provide this instance to all other objects solve the problem: A global class is frequently created and destroyed   1. Lazy mode public class Singl ...

Posted by FourthChapter on Wed, 24 Jun 2020 20:54:18 -0700

Deep analysis of JVM class loading mechanism

get ready: Markdown authoring tool Youdaoyun notes Idea development tools GItHub project address analysis: The whole process of class loading and running: When we use the java command to run the main function of a class to start the program, we first need to load the main class into the JVM through th ...

Posted by khaitan_anuj on Tue, 23 Jun 2020 03:23:00 -0700