In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use LockSupport under java concurrent package". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use LockSupport under the java concurrent package".
Java.util.concurrent.locks.LockSupport
Concept: use LockSupport to block and wake up threads. The method to block the thread: public static void park (): blocks the current thread and returns only if the unpark () method is called or the current thread is interrupted. Public static void parkNanos (long nanos) public static void parkUntil (long deadline) wakes up threads: public static void unpark (Thread thread): wakes up blocked threads. In Java6, LockSupport adds three methods: public static void park (Object blocker) public static void parkNanos (Object blocker, long nanos) public static void parkUntil (Object blocker, long deadline) parameter: blocker: used to identify the object that the current thread is waiting for (that is, blocking object), mainly used for troubleshooting and system monitoring. When a thread dump, the park () method with blocker parameter has the following more content than the park () method without blocker parameter (that is, indicates the type of blocking object):-parking to wait for (com.jxn.test.TestLockSupport) indicates: 1) when a thread (due to the use of the synchronized keyword) blocks on an object Through the thread dump, you can see the blocking object of the thread, so you can easily locate the problem. 2) when using the park () method without blocker parameter in LockSupport to block the object, the blocking object of the thread cannot be seen through the thread dump; therefore, the park () method with blocker parameter is provided in java6 to solve this problem. At this point, I believe you have a deeper understanding of "how to use LockSupport under the java concurrent package". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.