In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is Semaphore". In daily operation, I believe many people have doubts about what is Semaphore. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is Semaphore?" Next, please follow the editor to study!
Semaphore (semaphore)
Note that the alien sends out a certain amount of signal (permits). Other aliens receive the signal and use it (acquire), and then tell the sender to stop using it (release). If the signal is used up, we can only wait.
Purpose: multi-thread running current limit, flow control, database thread pool control, control sequence execution
Provide both fair and unfair ways.
Class ZeroEvenOdd {private int n; private Semaphore z = new Semaphore (1); private Semaphore e = new Semaphore (0); private Semaphore o = new Semaphore (0); public ZeroEvenOdd (int n) {this.n = n;} / / printNumber.accept (x) outputs "x", where x is an integer. Public void zero (IntConsumer printNumber) throws InterruptedException {for (int I = 0 bori)
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.