Method to create thread 1. The class inherits Thread and overrides the run() method 2. The class implements the Runnable interface and overrides the run() method (no return value, no exception will be thrown) 3. Implement the Callable interface and implement the call() method (with a return value and an exception will be thrown) To […]
Tag: finalize
Analysis of the impact of finalize method rewriting on GC
This is my second day participating in the November update challenge. For details, please check: 2021 Last Update Challenge Regarding the finalize method of Object, more than 99% of people may not have paid attention to it in daily development, because business development rarely rewrites the finalize method; most developers’ knowledge of finalize is “interview […]
The difference between final, finally and finalize in Java
1.final keyword Let’s talk about final first. It can be used in four places: Define variables, both static and non-static. Define the parameters of the method. Define the method. Define the class. Let’s review the role of final in each case in turn. 1.1 Define variables, including static and non-static. Define method parameters First case: […]
Effective Third Edition Chinese-English | Avoid finalizers and cleanup methods
Article directory Effective Third Edition foreword Avoid finalizers and cleaners Summarize Effective third edition Foreword Hello everyone, this is Rocky Programming Diary , I like back-end architecture and middleware source code, and I am currently reading effective-java books. At the same time, I also share my notes and codes when I was studying the book […]
Java ~ Reference ~ FinalizerHistogram [source code]
Foreword Articles Related series: “Java ~ Reference [Catalogue]” (continuously updated) Related series: “Java ~ Reference ~ FinalizerHistogram【Source Code】” (learning process/more Omissions / for reference only / no longer updated) Related series: “Java ~ Reference ~ FinalizerHistogram [Summary]” (Learning Summary/Latest and Most standard/continuously updated) Related series: “Java ~ Reference ~ FinalizerHistogram【Questions】” (Learning Answers/Continuous Updates ) Involved […]
AbandonedConnectionCleanupThread$ConnectionFinalizerPhantomReference memory overflow
I checked the information on the Internet, and sorted it out here according to my own situation, for your study and reference. Directory 1. Phenomenon 2. Mysql-connector-java source code analysis 3. Solution 3.1. Configure disableAbandonedConnectionCleanup 3.2. Violent solution —– Timing GC 4. What is a phantom reference 5. Is the associated object really recycled? 6. […]
[Java] final, finally, finalize
Article directory final, finally, finalize() final finally finalize() final, finally, finalize() The meanings and functions of final, finally, and finalize are as follows: The final keyword is used to declare an immutable variable, a non-inheritable class, or a non-overridable method. If a variable is modified with final, the value of the variable can no longer […]
Final, finally, finalize of Java keywords
1. final–final modifier Modified attributes: Attributes and local variables modified by final modifiers cannot be reassigned (see Example 1 below), so in order to save memory space, attributes modified by final At the same time, it is modified by static, and the customary writing order is static final. If it is defined as static, it […]
JavaSEWhat is the difference between final, finally and finalize?
Article directory 1. final 2. finally 3. finalize 1. final “final” is a keyword in Java, used to represent entities that cannot be changed or inherited. It can be applied to variables, methods and classes. final variables In Java, if a variable is declared as “final”, then it is considered constant and its value cannot […]
[Solved] The difference between java error and exception try catch finally; throws; final finally finalize
Exception/Error: During the running of the program, some unexpected effects may occur, which will definitely prevent our program from executing according to the instructions; This unexpected effect must be thrown out to tell us; In java there is a defined rule Throwable (throwable) Error error; usually something physical; a problem with the JVM itself; program […]