In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what code examples are in Disruptor-07, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Public class Test {private static Logger logger = LogManager.getLogger (); @ SuppressWarnings ("unchecked") public static void main (String [] args) throws InterruptedException {/ / The factory for the event TestEventFactory factory = new TestEventFactory (); / / Specify the size of the ring buffer, must be power of 2. Int bufferSize = 1024 / Construct the Disruptor Disruptor disruptor = new Disruptor (factory, bufferSize, DaemonThreadFactory.INSTANCE, ProducerType.SINGLE, new BlockingWaitStrategy ()); / / Create EventHandler TestEventHandler handler1 = new TestEventHandler ("handler1"); TestEventHandler handler2 = new TestEventHandler ("handler2"); TestEventHandler handler3 = new TestEventHandler ("handler3") TestEventHandler handler4 = new TestEventHandler ("handler4"); / / Connect the handler int count = 100; / / Unicast is in WorkPool mode, and the three WorkHandler are executed a total of 100 times. / / when Event arrives, which WorkHandler is scheduled is uncertain. / / disruptor.handleEventsWithWorkerPool (handler1, handler2, handler3); / / MulticastTest concurrent processing method: 3 EventHandler, each executed 100 times for a total of 300 times; / / when each Event arrives, the processing order of the EventHandler is uncertain. / / concurrent (handler1, handler2) Handler3) / / EventHandler:handler1--85:k-v / / EventHandler:handler3--85:k-v / / EventHandler:handler2--85:k-v / / EventHandler:handler1--86:k-v / / EventHandler:handler3--86:k-v / / EventHandler:handler2--86:k -v handler3 / / EventHandler:handler1--97:k-v / / EventHandler:handler2--97:k-v / / EventHandler:handler3--97:k-v / / EventHandler:handler1--98:k-v / / EventHandler:handler2--98:k-v / / EventHandler:handler3--98: KMurv / / EventHandler:handler1--99:k-v / / EventHandler:handler2--99:k-v / / EventHandler:handler3--99:k-v / / EventHandler:handler1--100:k-v / / EventHandler:handler2--100:k-v / / EventHandler:handler3--100: KMurv / / disruptor.handleEventsWith (handler1) .handleEventsWith (handler2) .handleEventsWith (handler3) / / Diamond / / schedule disruptor.handleEventsWith (handler1) .handleEventsWith (handler2,handler3) .handleEventsWith (handler4) according to handler1- > concurrent (handler2, hander3)-> handler4; / / Start the Disruptor, starts all threads running disruptor.start (); / / Get the ring buffer from the Disruptor to be used for publishing. RingBuffer ringBuffer = disruptor.getRingBuffer (); TestEventProducer producer = new TestEventProducer (ringBuffer); for (int I = 1; I
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.