In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "specific operation plan of Event in Python Library". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the specific operation plan of Event in Python Library".
This corresponds to the .NET ManualResetEvent and is used to collaborate among multiple threads. Event.wait () waits for the event signal to continue execution, set () sets the signal so that the waiting thread can execute, and clear () clears the signal.
Event1 = Event () event2 = Event () def test1 (): for i in range (5): event1.wait ()
Wait for the signal
Print currentThread () .name, I event1.clear ()
When the execution is complete, clear the flag (flag) so that the next time you wait (), you need to wait for notification again.
Event2.set ()
Set another wait event to signal another thread.
Def test2 (): for i in range (5): event2.wait () print currentThread (). Name, I event2.clear () event1.set () Thread (target = test1). Start () Thread (target = test2). Start () event1.set ()
Remember to activate one first, or they'll all be there waiting to die. Output:
$. / main.py Thread-1 0 Thread-2 0 Thread-1 1 Thread-2 1 Thread-1 2 Thread-2 2 Thread-1 3 Thread-2 3 Thread-1 4 Thread-2 4 Thank you for reading, the above is the content of "the specific operation plan of Event in Python Library". After the study of this article, I believe you have a deeper understanding of the specific operation plan of Event in Python Library, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.