How to understand java basics_generic self-limitation?

The Mystery of SelfBounded In the explanation of generics in "Java Programming Thoughts", self-defined types are mentioned: class SelfBounded<T extends SelfBounded<T>>{} The author's definition of it is "I am creating a new class that inherits from a generic type that receives its own class name as a paramete ...

Posted by jpratt on Fri, 17 Feb 2023 03:37:59 +0300

Jigsaw puzzle game (1.0) incomplete version

jigsaw puzzle 1. Project introduction Jigsaw puzzle game, a complete picture is divided into 16 parts, reassembled into the original picture, and only one grid can be moved at a time. In this project, it is 4*4 squares, that is, 16 scattered pictures, which are broken up each time The pictures are all random. 1. Game start interface The pic ...

Posted by leetcrew on Tue, 14 Feb 2023 23:12:26 +0300

How Java creates threads from glibc to kernel thread

How Java creates threads (2) From glibc to kernel thread background In the previous section, we discussed how java threads are created, and looked at what has been done in the source code from the java code level to the jvm level. The whole process is still relatively complicated. I will paste the call timing diagram summarized in the previou ...

Posted by rantsh on Sat, 11 Feb 2023 23:12:18 +0300

Java 17 record class learning

Java Record A Java record is a class whose sole purpose is to drive programming with immutable data. Let's look at a simple example. public record Data( int x, int y) Here we create a record with headers x and y. The x and y here are called the components of the record. An equivalent class would look like this: public class Data { ...

Posted by mk_silence on Wed, 25 Jan 2023 09:58:44 +0300

How threads in the thread pool are reused

Preface I believe everyone knows the relationship between processes and threads. I won’t explain too much here. Since a process is composed of multiple threads, the thread pool is composed of several thread queues. The concurrency is relatively high. In some scenarios, we usually create a thread pool to perform tasks, instead of creating ...

Posted by cesarcesar on Sat, 24 Dec 2022 13:42:28 +0300

You must know JavaFile

The File object represents a path, which can be the path of a file or the path of a folderThis path can exist or not exist File structure method nameillustratepublic File(String pathname)Create a file object based on the file pathpublic File(String parent,String child)Creates a file object from a parent pathname string and a child pathname st ...

Posted by Idri on Thu, 22 Dec 2022 08:47:18 +0300

Xuanzi Java Basic Notes 2

User interaction Basic Scanner package CH02_JAVAProcessControl; //Basic Scanner import java.util.Scanner; //Guide package public class XZ01_UserInteraction { public static void main(String[] args) { Scanner input = new Scanner(System.in); //Create a Scanner object System.out.println("Please enter 1"); if (input.h ...

Posted by marsooka on Mon, 28 Nov 2022 07:52:35 +0300

Java - what is thread

​ ​ Event address: CSDN 21 Day Learning Challenge 1. What is a thread To understand what a thread is, you must first understand a process Process: A simple understanding is the running program Thread: A thread is the smallest unit in a process, and there is at least one thread in a process There is no concept of a process in the ...

Posted by rajmohan on Mon, 12 Sep 2022 21:15:45 +0300

ReentrantLock lock related methods

catalogue Implementation class of Lock interface ReentrantLock method ReentrantLockTest test Thread for testing t1 test Release the reentry lock correctly Get the current number of reentries t1t2 test Use the islocked() method to detect the lock state t1t3 test Use the trylock method to attempt to acquire a lock U ...

Posted by wxflint on Sun, 04 Sep 2022 22:34:19 +0300

[Java]Basic knowledge of interview

#[Java]Basic knowledge of interview review it yourself foreword Looking for a job recently, discipline the basics of Java 1. Basic data types 1. Difference and conversion between int and Interger the difference 1. Integer is a wrapper class for int, which is a basic data type of java 2. Integer variables must be instantiated ...

Posted by tengkie on Sun, 04 Sep 2022 12:38:21 +0300