MCPcopy Create free account
hub / github.com/MorvanZhou/tutorials / multithreading

Function multithreading

threadingTUT/thread5_GIL.py:15–26  ·  view source on GitHub ↗
(l)

Source from the content-addressed store, hash-verified

13 q.put(res)
14
15def multithreading(l):
16 q = Queue()
17 threads = []
18 for i in range(4):
19 t = threading.Thread(target=job, args=(copy.copy(l), q), name='T%i' % i)
20 t.start()
21 threads.append(t)
22 [t.join() for t in threads]
23 total = 0
24 for _ in range(4):
25 total += q.get()
26 print(total)
27
28def normal(l):
29 total = sum(l)

Callers 1

thread5_GIL.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected