In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "FastThreadLocal and Recycler case Analysis of Netty". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "FastThreadLocal and Recycler case Analysis of Netty" can help you solve the problem.
Overview
FastThreadLocal was briefly introduced when we analyzed the out-of-heap memory allocation. It is similar to JDK's ThreadLocal, and it is also used to ensure the object sharing of unified threads under multithreaded conditions, but the performance of FastThreadLocal defined in netty is higher than that of jdk's ThreadLocal. The specific reasons will be analyzed in later sections.
Recyler should be no stranger to us, because in the previous chapter, Recyler is used in many places.
Recyler is a lightweight object recycle bin implemented by netty. Many objects are not directly handed over to gc after use, but are recycled through the object Recycle Bin in order to reuse objects and reduce gc pressure.
For example, the recycling of ByteBuf objects, because ByteBuf objects are frequently created in netty and take up a large amount of memory space, they will be recycled through the object Recycle Bin after use, which has achieved the purpose of resource reuse.
This chapter analyzes two concurrent tool classes, FastThreadLocal and Recyler.
Section 1: the use and creation of FastThreadLocal first let's look at the simplest demopublic class FastThreadLocalDemo {final class FastThreadLocalTest extends FastThreadLocal {@ Override protected Object initialValue () throws Exception {return new Object ();}} private final FastThreadLocalTest fastThreadLocalTest; public FastThreadLocalDemo () {fastThreadLocalTest = new FastThreadLocalTest ();} public static void main (String [] args) {FastThreadLocalDemo fastThreadLocalDemo = new FastThreadLocalDemo () New Thread (new Runnable () {@ Override public void run () {Object obj = fastThreadLocalDemo.fastThreadLocalTest.get (); try {for (int iTuno)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.