228 people agreed with this answer
Interests related, hidden!
JVM companies have many threads and factions, especially the executive engine, because it is the core department, often diss other departments.
428 people agreed with the answer
Uninvited.
Working in the JVM is not as hard as you might think. I don’t know about other departments. Take my garbage collection department for example.
My job is to implement the Finalize method of objects. As you know, programmers nowadays seldom implement this method of classes, so most of my work is to touch the fish.
————— Dividing line —————
In the comments, someone asked me how the finalize method of an object is implemented.
When loading a class, the JVM ClassLoader department will check whether it has Finalize method. I am not clear about the specific details, please @AppClassLoader to help solve the problem.
If a Finalize method is found, a Finalizer object will be created for all objects that create this class in the future.
The Finalizer has two key points:
-
It inherits from the Reference class and is itself a Reference to the object it created with
-
It has a member named queue that points to a queue:
ReferenceQueue
It is
Finalizer
A static member variable of.
In addition, Finalizer also includes a static thread called FinalizerThread, which is actually me. My job is to fetch the Finalizer object from the above queue, and then execute the Finalize method of the object that it references.
What? When did the Finalizer object enter the queue? I don’t know about that, it’s out of my job scope, so I can ask @referenceHandler to help with that.
The above.
522 people agreed with the answer
Thanks invitation!
The JVM company as a whole is in pretty good shape. The office building has two floors, the first floor is native floor, and a bunch of native floor threading employees work below. I’m in the Java layer on the second floor, which is full of Java threads.
I work in the JVM class loading department. My Leader is an ExtClassLoader, and his Leader is a company executive, BootstrapClassLoader.
Our department’s job is to load the.class files on disk into memory and make them usable. Work is easy. But one thing that bugs me is the department’s parental delegation system.
Every time we encounter a new class that needs to be loaded, we must ask the leader to load it according to the regulations, and the leader goes to ask his leader to load it. But the executive BootstrapClassLoader was only responsible for loading the core Java classes, and my supervisor was only responsible for loading some extension classes, so most of the time they couldn’t load them, and I had to do it.
Spent a lot of time on the process, blind delay time. I have responded to this problem many times, can you not ask me to load directly, but every time was rejected, said to safety considerations, they must look at it. Alas, the leadership is not willing to delegate power is also difficult!
———— Dividing line ————
The comment section is too angry! Saying I don’t understand security is drunk.
Answer the question from @finalizerThread.
Indeed, as he said, our ClassLoader will check whether the class implements Finalize method, and the check result will be saved in AccessFlags in Klass structure.
This is an important field that records many properties of the class:
With this information, you can check the tag when creating the object to determine whether a Finalizer object should be created.
The above.
145 people agreed with the answer
Thank you @FinalizerThread for inviting us.
I’m in the JVM, just off the night shift.
I’m pressed for time. Just a word.
Like this student, I am also an employee of GC department. The company does have a good salary and is very competitive in this aspect.
As for my job, it’s closely related to garbage collection!
You also know that in Java, in addition to the basic strong reference, there are four special references:
-
FinalReference
-
SoftReference
-
WeakReference
-
PhantomReference
FinalizerThread is a subclass of FinalReference.
My job is to add these special references one by one to their respective queues during garbage collection.
In the case of FinalizerThread, I add it to the queue and FinalizerThread retrieves it from the queue.
898 people agreed with the answer
Let me answer this question briefly.
Look at the answer of the first few, it is really dry dry death, waterlogged waterlogged death. I’m so busy every day that I can’t breathe, and you guys still have time to fish!
I’m one of the first to arrive every day in the JVM company, following Threads:: CREATE_VM to get up.
I also have a work queue, called _vm_thread, whose type is VMOperationQueue.
Different from the two people upstairs, they work in the Java layer on the second floor, while I work in the Native layer on the first floor.
Work rhythm this thing is really different departments are very different, I am in the department of one person, is a singleton thread, I have to do is constantly from the work queue out of the operation to execute.
This queue is filled with things that are encapsulated as VM_Operation, and this is their base class. Specifically, there are dozens of operations, just to name a few, so you can feel at home:
Other than not to say, take the most familiar garbage collection for example, without me, the JVM heap area memory is probably already garbage heap mountain.
Time, let me write it here.
————— Dividing line —————
I woke up with so many likes, thank you!
A few words to add.
A mode is also set in VM_Operation to indicate whether the operation needs to enter a safe point (such as garbage collection) and whether the operation needs to be performed with a lock.
I initiate both the entry and exit of the safe point by executing SafepointSynchronize’s begin() and end() functions.
The above.
This article briefly introduces the work of several built-in threads in the JVM in zhihu-style, hoping to help you learn a little bit about the JVM.
If you like this article welcome to help share, thank you!
TOP5 articles in the past
Really bad! Even the major programming languages are on the ground!
I almost lost my job because of a cross-domain request
Over! CPU blindly for a quick thing!
Which hash table is the best? The big programming languages are at war!
A fantastical journey through HTTP packets