In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to understand Netty locks, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
1. Analyze the three core elements of synchronization problem.
Atomicity: "it can't be unassailable without one go", such as iTunes + under high concurrency.
Visibility: "the changes you make are invisible to others."
Order: "not playing cards according to the routine"
2. Classification of locks
Competitive attitude: optimistic lock (atomic class in java.util.concurrent package) and pessimistic lock (synchronized)
Whether the person waiting for the lock is fair: fair lock new ReentrantLock (true) and unfair lock new ReentrantLock ()
Whether it can be shared or not: shared lock and exclusive lock-ReadWriteLock, whose read lock is shared lock and its write lock is exclusive lock
3. Five key points for Netty to play with lock 3.1, the object and scope of lock are concerned-> reduce granularity
Example: initialize channel (io.netty.bootstrap.ServerBootstrap#init)
Synchronized method-> Synchronized block
Void init (Channel channel) throws Exception {Map, Object > attrs = this.attrs0 (); synchronized (attrs) {Iterator var5 = attrs.entrySet (). Iterator (); while (true) {if (! var5.hasNext ()) {break;} Entry
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.