example code mainly realizes the maximum number of Python programming test computer to open the maximum number of threads, the specific implementation of the code as follows.

 /usr/bin/env Python #coding=UTF-8 #! Import threading import time, random sys, class Counter: def __init__ (self): self.lock = threading.Lock (self.value = 0) def increment (self): self.lock.acquire (self.value) = value = self.value + 1 (self.lock.release) return value counter (cond) = Counter = threading.Condition (class Worker) (threading.Thread): def run (self): Print (self.getName), "created." cond.acquire (#for) I in range (10): pretend we're doing something that takes # 10? 00 MS #value = counter.increment (time.sleep) # (random.randint (10, 100) / 1000 (#print) self.getName (cond.wait)). " Task "," finished "(cond.release) if __name__'__main__': try: for I = in range (3500): Worker (.Start) (start) # a worker except BaseException e: print": "type anomaly (E), e time.sleep (5) print" maxium "i=, I finally: cond.acquire (cond.notifyAll) (cond.release) (time.sleep) (3) print (threading.currentThread) (.GetName)," quit "


above is the summary about the python programming computer open test the maximum number of threads for example The full content of the code, I hope to help you. Interested friends can continue to refer to other relevant topics of the station, if there are shortcomings, welcome the message. Thank you for the support of our friends!

This paper fixed link:http://www.script-home.com/python-programming-test-computer-to-open-the-case-code-for-the-maximum-number-of-threads.html | Script Home | +Copy Link

Article reprint please specify:Python programming test computer to open the case code for the maximum number of threads | Script Home

You may also be interested in these articles!